Note that there are some explanatory texts on larger screens.

plurals
  1. PONservicebus serization issue of derived types
    primarykey
    data
    text
    <p>for the context setting, I am exchanging messages between my nServiceBus client and nSerivceBus server. its is the namespace xyz.Messages and and a class, Message : IMessage</p> <p>I have more messages that are in the other dlls, like xyz.Messages.Domain1, xyz.Messages.Domain2, xyz.Messages.Domain3. and messages that derive form that base message, Message.</p> <p>I have the endpoints defined as like : </p> <pre><code> at client &lt;UnicastBusConfig&gt; &lt;MessageEndpointMappings&gt; &lt;add Messages="xyz.Messages" Endpoint="xyzServerQueue" /&gt; &lt;add Messages="xyz.Messages.Domain1" Endpoint="xyzServerQueue" /&gt; &lt;add Messages="xyz.Messages.Domain2" Endpoint="xyzServerQueue" /&gt; &lt;/MessageEndpointMappings&gt; &lt;/UnicastBusConfig&gt; </code></pre> <p>at Server</p> <pre><code>&lt;UnicastBusConfig&gt; &lt;MessageEndpointMappings&gt; &lt;add Messages="xyz.Messages" Endpoint="xyzClientQueue" /&gt; &lt;add Messages="xyz.Messages.Domain1" Endpoint="xyzClientQueue" /&gt; &lt;add Messages="xyz.Messages.Domain2" Endpoint="xyzClientQueue" /&gt; &lt;/MessageEndpointMappings&gt; &lt;/UnicastBusConfig&gt; </code></pre> <p>and the bus initialized as </p> <pre><code> IBus serviceBus = Configure.With() .SpringBuilder() .XmlSerializer() .MsmqTransport() .UnicastBus() .LoadMessageHandlers() .CreateBus() .Start(); </code></pre> <p>now when i try sending instance of Message type or any type derived types of Message, it successfully sends the message over and at the server, i get the proper type.</p> <p>eg. </p> <pre><code>Message message= new Message(); Bus.Send(message); // works fine, transfers Message type message = new MessageDerived1(); Bus.Send(message); // works fine, transfers MessageDerived1 type message = new MessageDerived2(); Bus.Send(message); // works fine, transfers MessageDerived2 type </code></pre> <p>My problem arises when any type, say MessageDerived1, contains a member variable of type Message, and when i assign it to a derived type, the type is not properly transferred over the wire. It transfers only as Message type, not the derived type.</p> <pre><code>public class MessageDerived2 : Message { public Message message; } MessageDerived2 messageDerived2= new MessageDerived2(); messageDerived2.message = new MessageDerived1(); message = messageDerived2; Bus.Send(message); // incorrect behaviour, transfers MessageDerived2 correctly, but looses type of MessageDerived2.Message (it deserializes as Message type, instead of MessageDerived1) </code></pre> <p>any help is strongly appreciated.</p> <p>Thanks TJ</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload