Jan
Jan

Reputation: 6828

NServiceBus without spamming my solution with IMessage/NServiceBus references

Has anyone found a smart way to use NServiceBus, without having to implements that useless IMessage marker interface for all messages?

Especially, when using DomainEvents, I would absolutely hate to couple my domains to a specific servce bus implementation.

Upvotes: 3

Views: 1248

Answers (4)

Emil Lerch
Emil Lerch

Reputation: 4466

I just noticed that Udi is adding an Unobtrusive Mode to NServiceBus 3.0. It appears that will address the issue. There's even a sample writeup, but you would have to pull the latest off github at this point (Feb 2012). If you're willing to put up with some potential instability to get pure POCO messages, you might give it a try.

Upvotes: 5

gonzalo.vinas
gonzalo.vinas

Reputation: 71

Six months later, still nothing about this issue (fix/improve) ??

Summary of possible solutions: 1) ILMerge or.. 2) Custom Dispatcher for custom wrapped messages.

All this because of the IMessage marker interface.

Upvotes: 0

Shahid
Shahid

Reputation: 1

You might be able to create your own interfaces implementing the NSB marker interface and then ILMerge the NSB dependencies into your own DLL. This should allow you to only require references to your own Dll and no external references to NSB.

Its what NSB does for its own dependencies so you should be able to extend the idea, be sure to check out the pitfalls of this approach though - Udi blogged about it recently

http://www.udidahan.com/2010/08/01/cautiously-merging-il/

Upvotes: 0

Udi Dahan
Udi Dahan

Reputation: 12057

The IMessage interface is needed so that NServiceBus can automatically register those types in the serializer. When using domain events, it isn't recommended to publish them directly on the bus - instead, a domain event handler would translate them to service-level events (which inherit IMessage).

Upvotes: 1

Related Questions