Re: [masstransit-discuss] Windsor 2.6.2.0: UseXmlSerializer doesn't seems to work

84 views
Skip to first unread message

Dru Sellers

unread,
Aug 20, 2012, 10:26:22 AM8/20/12
to masstrans...@googlegroups.com
i need to see your message class definition

-d

On Mon, Aug 20, 2012 at 9:14 AM, Nir Varon <nva...@gmail.com> wrote:
Hi,

This is pretty much a noub question, but I'm trying to work with MSMQ with the following configuration:
            configurator.ReceiveFrom("msmq://localhost/TestQueue");
            configurator.UseMsmq();
            configurator.VerifyMsmqConfiguration();

            configurator.Subscribe(x => x.LoadFrom(container));
            configurator.UseXmlSerializer();
            configurator.UseLog4Net();
            configurator.EnableMessageTracing();

And i'm getting the following error when trying to use a message with abstract class in one of the properties.
System.Runtime.Serialization.SerializationException: Failed to deserialize the message ---> Newtonsoft.Json.JsonSerializationException: Could not create an instance of type XXXX. Type is an interface or abstract class and cannot be instantated.

I have two questions:
1. How can I send this kind of message?
2. Why the source of this exception is from JsonSerializer, when I explicitly set the configuration to use XmlSerializer?

Your help please,
Nir

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/F4cmByvU998J.
For more options, visit https://groups.google.com/groups/opt_out.



Nir Varon

unread,
Aug 20, 2012, 10:31:24 AM8/20/12
to masstrans...@googlegroups.com
Thank you for the quick reply,
I'm trying to publish ResponseReadyMessage and get an error on the highlighted type in AtomicAction class.
Here is my message class defenition:
public abstract class InternalMessage
    {
        public Guid SessionId { get; set; }

        protected InternalMessage(Guid sessionId)
        {
            SessionId = sessionId;
        }
    }
public class ResponseReadyMessage : InternalMessage
    {
        public BPNodeDTO BpNodeDto { get; set; }
        public ResponseReadyMessage(Guid sessionId, BPNodeDTO bpNodeDto) : base(sessionId)
        {
            Check.ParameterIsNotNull(bpNodeDto, "bpNodeDto");

            BpNodeDto = bpNodeDto;
        }
    }
public class BPNodeDTO
    {
        public AtomicAction[] Actions { get; set; }
    }
public class AtomicAction
    {
        public int Id { get; set; }
        public int ActionId { get; set; }
        public int ExecutionOrder { get; set; }
            
        public InteractionBase Prolouge { get; set; }
        public OperationInfo Operation { get; set; }
        public InteractionBase Epilouge { get; set; }
    }

On Monday, August 20, 2012 5:26:22 PM UTC+3, Dru wrote:
i need to see your message class definition

-d

On Mon, Aug 20, 2012 at 9:14 AM, Nir Varon <nva...@gmail.com> wrote:
Hi,

This is pretty much a noub question, but I'm trying to work with MSMQ with the following configuration:
            configurator.ReceiveFrom("msmq://localhost/TestQueue");
            configurator.UseMsmq();
            configurator.VerifyMsmqConfiguration();

            configurator.Subscribe(x => x.LoadFrom(container));
            configurator.UseXmlSerializer();
            configurator.UseLog4Net();
            configurator.EnableMessageTracing();

And i'm getting the following error when trying to use a message with abstract class in one of the properties.
System.Runtime.Serialization.SerializationException: Failed to deserialize the message ---> Newtonsoft.Json.JsonSerializationException: Could not create an instance of type XXXX. Type is an interface or abstract class and cannot be instantated.

I have two questions:
1. How can I send this kind of message?
2. Why the source of this exception is from JsonSerializer, when I explicitly set the configuration to use XmlSerializer?

Your help please,
Nir

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

Dru Sellers

unread,
Aug 20, 2012, 10:33:10 AM8/20/12
to masstrans...@googlegroups.com
what does InterationBase look like?

-d

To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/S23-jpM5mn0J.

Nir Varon

unread,
Aug 20, 2012, 10:34:13 AM8/20/12
to masstrans...@googlegroups.com
public abstract class InteractionBase
    {
        public virtual string DialogCaption { get; set; }
        public virtual string CancelButtonCaption { get; set; }
-d

-d


To unsubscribe from this group, send email to masstransit-discuss+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

Dru Sellers

unread,
Aug 20, 2012, 10:43:00 AM8/20/12
to masstrans...@googlegroups.com
Try changing 'InterationBase' to an interface rather than an abstract class.

Not sure why you are getting the JSON, can you send me the diagnostics output?

-d

To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/wB-ZtKjPhGUJ.

Nir Varon

unread,
Aug 20, 2012, 11:44:05 AM8/20/12
to masstrans...@googlegroups.com
I changed the class to interface and now I don't get any exception but I'm getting a dynamic implemention 
of the interface and that cause loss of data from the derived classes.
There is an option in Newton JsonSerializer to pass the concrete type to the serialized JSON,
Is there a way that we can use this option?

How do I get the diagnostics output? this function doesn't exist :
sbc.WriteDiagnosticsToFile("a_file.txt")

Nir 
-d

-d

To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/S23-jpM5mn0J.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.
-d

-d

To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/S23-jpM5mn0J.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

Travis Smith

unread,
Aug 20, 2012, 11:50:51 AM8/20/12
to masstrans...@googlegroups.com
You must use binary serialization since all typing is done at compile
time unless you do dynamic invocation. Since it's a child property you
likely won't have access to the right type information even using
dynamic invocation.

-Travis
>>>>>>> masstransit-dis...@googlegroups.com.
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msg/masstransit-discuss/-/F4cmByvU998J.
>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>
>>>>>>>
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "masstransit-discuss" group.
>>>>> To post to this group, send email to masstrans...@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> masstransit-dis...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msg/masstransit-discuss/-/S23-jpM5mn0J.
>>>>>
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>
>>>>>
>>>>
>>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "masstransit-discuss" group.
>>> To post to this group, send email to masstrans...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> masstransit-dis...@googlegroups.com.
>>>>>>> masstransit-dis...@googlegroups.com.
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msg/masstransit-discuss/-/F4cmByvU998J.
>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>
>>>>>>>
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "masstransit-discuss" group.
>>>>> To post to this group, send email to masstrans...@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> masstransit-dis...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msg/masstransit-discuss/-/S23-jpM5mn0J.
>>>>>
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>
>>>>>
>>>>
>>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "masstransit-discuss" group.
>>> To post to this group, send email to masstrans...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> masstransit-dis...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/masstransit-discuss/-/wB-ZtKjPhGUJ.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "masstransit-discuss" group.
> To post to this group, send email to masstrans...@googlegroups.com.
> To unsubscribe from this group, send email to
> masstransit-dis...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/masstransit-discuss/-/sT3R8xaDq4IJ.

Dru Sellers

unread,
Aug 20, 2012, 11:51:03 AM8/20/12
to masstrans...@googlegroups.com
https://github.com/MassTransit/MassTransit/blob/master/src/MassTransit/Diagnostics/IntrospectionExtensions.cs#L38 

is the method to call.

You are correct that you are seeing a dynamic implementation of the interface. My guess is that you may need to reevaluate how you approach your message design in light of how MT does things. You may find a much more elegant model. 

-d

To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/sT3R8xaDq4IJ.

Chris Patterson

unread,
Aug 21, 2012, 12:18:05 AM8/21/12
to masstrans...@googlegroups.com
Xml is done using JSON.NET, since it's faster to go to Json->Xml, and more consistent.

And using things like virtual and abstract classes in message definitions is not a good idea, look at using only interfaces with pure types.

Avi Levi

unread,
Sep 27, 2012, 3:58:07 AM9/27/12
to masstrans...@googlegroups.com
Hi Chris, 

"And using things like virtual and abstract classes in message definitions is not a good idea, look at using only interfaces with pure types."

would you mind elaborating on this a bit? I'll be happy to get your opinion on message definition.

thanks,
Avi.
-d


-d

-d

To unsubscribe from this group, send email to masstransit-discuss+unsubscribe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/wB-ZtKjPhGUJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/sT3R8xaDq4IJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

Dru Sellers

unread,
Sep 27, 2012, 10:40:58 AM9/27/12
to masstrans...@googlegroups.com
what are your goals in wanting to use them?

-d

To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/mKyJiHcWMDMJ.

Avi Levi

unread,
Sep 27, 2012, 3:49:51 PM9/27/12
to masstrans...@googlegroups.com
well, I don't have a specific scenario in mind, just interested why you feel like this is a bad idea.

Avi.

Chris Patterson

unread,
Sep 27, 2012, 3:52:51 PM9/27/12
to masstrans...@googlegroups.com
I could write a pretty extensive reply, but in the words of Udi:

http://www.udidahan.com/2011/01/13/polymorphism-and-messaging/



On Thu, Sep 27, 2012 at 2:58 AM, Avi Levi <avil...@gmail.com> wrote:
>>>>>>>>>> masstransit-dis...@googlegroups.com.
>>>>>>>>>> To view this discussion on the web visit
>>>>>>>>>> https://groups.google.com/d/msg/masstransit-discuss/-/F4cmByvU998J.
>>>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "masstransit-discuss" group.
>>>>>>>> To post to this group, send email to masstrans...@googlegroups.com.
>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>> masstransit-dis...@googlegroups.com.
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msg/masstransit-discuss/-/S23-jpM5mn0J.
>>>>>>>>
>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "masstransit-discuss" group.
>>>>>> To post to this group, send email to masstrans...@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> masstransit-dis...@googlegroups.com.
>>>>>>>>>> masstransit-dis...@googlegroups.com.
>>>>>>>>>> To view this discussion on the web visit
>>>>>>>>>> https://groups.google.com/d/msg/masstransit-discuss/-/F4cmByvU998J.
>>>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "masstransit-discuss" group.
>>>>>>>> To post to this group, send email to masstrans...@googlegroups.com.
>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>> masstransit-dis...@googlegroups.com.
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msg/masstransit-discuss/-/S23-jpM5mn0J.
>>>>>>>>
>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "masstransit-discuss" group.
>>>>>> To post to this group, send email to masstrans...@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> masstransit-dis...@googlegroups.com.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msg/masstransit-discuss/-/wB-ZtKjPhGUJ.
>>>>>>
>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "masstransit-discuss" group.
>>>> To post to this group, send email to masstrans...@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> masstransit-dis...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msg/masstransit-discuss/-/sT3R8xaDq4IJ.
>>>>
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "masstransit-discuss" group.
>>> To post to this group, send email to masstrans...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> masstransit-dis...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "masstransit-discuss" group.
> To post to this group, send email to masstrans...@googlegroups.com.
> To unsubscribe from this group, send email to
> masstransit-dis...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/masstransit-discuss/-/mKyJiHcWMDMJ.

Avi Levi

unread,
Nov 29, 2012, 10:52:24 AM11/29/12
to masstrans...@googlegroups.com
actually, in this post Udi talks about polymorphism at the message's level, the issue discussed refers to message's payload and not the message itself.
the message contains a collection of items of different structure and the items are pure data, not containing behavior, do you still think it is a bad idea?
Reply all
Reply to author
Forward
0 new messages