0

I'm upgrading from 2.6 to 4.0. in 2.6, I have my website send the message to the Publisher service. The Publisher service then publishes the message to one or many subscribers.

However, in 4.0, one must send and IMessage and publish an IEvent. I can not send an IEvent. As far as I can see this leaves me two options. Either create two messages that are exactly the same and have one implement IMessage ( for the sending of the command to the publisher ) and one that implements IEvent ( for the publishing to subscribers ), or publish the IMessage, which in not auto-discoverable, and make sure all subscribers explicitly specify the messages they want.

Clearly the second method is the only plausible one (if it's even possible), but I'm hoping there is another way. Is there?

Kara
  • 6,115
  • 16
  • 50
  • 57
Raif
  • 8,641
  • 13
  • 45
  • 56

2 Answers2

0

(i'm assuming the web server and your back end services (publisher) are on the same domain)

You could have two messages, one a command coming form an action on the we site (e.g. CreateAccount) that has to be an IMessage (you can use the unobtrusive mode by the way), and a second message (an IEvent) something like AccountCreated, it would be published after the CreatAccount handler had done it's work.

If you want to publish an event directly from your web site, you can host an endpoint on your web server and publish an IEvent from there...

Andreas Öhlund has a short blog on the subject: http://andreasohlund.net/2011/12/08/introducing-ievent-and-icommand/

Mike Minutillo
  • 54,079
  • 14
  • 47
  • 41
Sean Farmar
  • 2,254
  • 13
  • 10
0

ok, so the issue is that we are not doing things quite as expected yet. I believe the proscribed sequence is

a) web input

b) command to publisher

c) publisher does something like save data

d) publisher publishes some new even "Hey I just saved!"

However what we are doing is a) web input

b) web app saves data

c) web app notifies publisher

d) publisher alerts all subscribers

In our case the command and the event are the exact same message. One is not supposed to publish an event from a web app for several reasons as mentioned HERE. So we are merely passing the message to a service and letting the service publish it.

The answer to my dilemma is to use a IMessage for the message ( this gets it to the publisher fine ) and then in our publishers and subscribers say

.DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("blahblahblah.Messages.Publishing"));

now the subscribers auto subscribe to my IMessage which of course is in the above namespace.

Raif
  • 8,641
  • 13
  • 45
  • 56