1 command with multiple handlers

558 views
Skip to first unread message

Loch

unread,
Dec 10, 2014, 11:12:31 AM12/10/14
to particula...@googlegroups.com

Nservicebus allows you to attach Icommand and ievent marker interface to messages in order to help enforce certain best practices.  I do notice i am still allowed to have multiple handlers for the same command.  

In andreas ohlund ' s pluralsite course on nservicebus he provides an example.

Is this considered bad practice? 

Is there any valid use case for doing this?

 


Mauro Servienti

unread,
Dec 10, 2014, 11:24:30 AM12/10/14
to particula...@googlegroups.com
Hi,

you can now get rid of the interfaces if you prefer using the unobtrusive mode:

having more than one handler in the same endpoint can be handy for a variety of reasons:

a) evolution/versioning: you can version your commands using commands inheritance (is a possible solution) and thus you can a handler for the “old” command and a handler for the new command what is happening in this case is that if someone sends the new command (that inherits from the old one) both handlers will be invoked;

b) security and validation: you can setup a “generic” handler handling “Object” or “IMessage” that will work as a catch all and for example perform common validation tasks in that handler, in this case you can specify message handling ordering:

The above are the first 2 that came to my mind,
.m
--
(no keyboard keys have been killed due to the really annoying OSX spell checker)
--
You received this message because you are subscribed to the Google Groups "Particular Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftw...@googlegroups.com.
To post to this group, send email to particula...@googlegroups.com.
Visit this group at http://groups.google.com/group/particularsoftware.
To view this discussion on the web visit https://groups.google.com/d/msgid/particularsoftware/6ab25624-b32e-4a2b-a4a8-08edfae05b25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages