tags:

views:

36

answers:

1

Is having the event handler in the subscriber required? For example:

Projects:

Crm.Events: NewUserCreated : IMessage {}

Crm.Publisher: console app publishes as Bus.Publish(new NewUserCreated());

Crm.Subscriber: console app subscribing to the NewUserCreated event.

Crm.EventHandlers NewUserCreatedHandler : IHandleMessages { ... }

Do I need the NewUserCreatedHandler in Crm.Subscriber or can I just reference the Crm.EventHandlers assembly in Crm.Subscriber so NSB can invoke the handler?

Thanks

A: 

You can just reference the eventhandler assembly. This is because NSB scan all assemblies in your bin directory for classed that implements IHandleMessages.

That said, can you explain why would you want to separate the messagehandlers from your "Crm.Subscriber" project?

Andreas
My thought was if I needed to change to subscriber from a console app to a windows service, I could simply reference that assembly into the windows service rather than copy files to windows service.
developer
The generic host process that comes with NServiceBus can do this for you automatically - see http://www.nservicebus.com/GenericHost.aspx
Udi Dahan
Thanks guys, it is all clear now. Is there a recommended/best practice/preferred way of creating projects in a solution? I know this is a generic question but I see people recommend create commands, events in separate projects. Are there other gotchas or recommendation on project structure in a solution?
developer