Friday, 15 July 2011

c# - How do I configure NServiceBus to scan an assembly for IMessage? -


I am working with code that I have not written and I am trying to understand that one of the functions I do not understand the way the particular part is working. In particular, there are three projects in my solution:

  API message event processor  

There is a folder inside the events message using the NSSSBbis with the API processor The tax message will define in the message / event . iMessage extended classes in Messaging / Events .

In a configuration file, I found these lines just for the bus to be shared by both the processor and the API:

  var conventionsBuilder = config.Conventions () ; ConferencesBuilder.Defining Aventives (T = & gt; T. Namespace! = Null & amp; amp; Technologies with Starters ("Day.Stepe.") & Amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; "Event"); Return Configuration;  

It was previously implemented, and sections of Messages / Events instead of the first code instead of IMessage was not extended was defined as where and what message might be eligible as now, since I have iMessage , I thought I could remove those 3 lines. However, when I do, no messages ever make it in my line from the API that the code that attempts to publish this code is Just do it. Publish

How should I configure this so that I do not need to reference the hard-coded string assembly where messages are? Scan code to solve any thing Interpretation wish that IMessage enhances and it can be published, which considers as a thing and it can be handled.

EDIT: According to the NServiceBus docs

  By default, NServiceBus scans all assemblies in the Endpoint Bin folder to find the types of implementations of their interfaces. So that it can be configured automatically  

and Messages.dll appears in both the API and the processor's bin . So when all of my IMessages are in Messages.dll , should not they be available to default / start / subscribe to default behavior? To wit. Should not remove 3 lines in question, there is no effect?

The hierarchy of an event, if you are not using a random configuration, The reason:

  Concrete Avent: Ivette: IMages  

The reason for this is that after viewing it source code, your message endpoint mapping processed as follows Are:

  foreach (mapping in message mapping points) {mapping.Configure ((messageType, address) = & gt; {var conventions = context.Settings get (summo LANs. IMS message type (message type). Event type (Message type) || Conventions type (message type)) {return;} if (conventions. ISET type (message type)) {router.novistorcentroute (message type , Address); Return;} Router Registrar message route (message type, address);}); }  

Convention. ISEType has a look implemented as follows:

  eventsCommunication cache. AppLine Communication (T, Type = & gt; IsEventTypeAction (Type));  

I will not give you a full call stack but basically, you end here:

  t => Typef (event). ISASSANABLEFLOM (T) & amp; Typeof (IEvent)! = T  

This will evaluate as a false to implement iMessage for a solid event, hence the RegisterEventRoute is never called for your event, but it will be treated as a IMessage , which adhere to different routing rules (only one route per IMessage ).


No comments:

Post a Comment