This project is read-only.

NServiceBus not able to PubSub object type, what is the workaround?

Oct 4, 2011 at 2:23 AM

public class TestMessage : IMessage
{
  public String Text { get; set; }
  public object SingleObject { get; set; }
}

public void PerformPublish()
{
  object a123; a123 = 123;
  var msg = new TestMessage()
  {
   Text = "Testing NSB Publish"
  };
  var msg1 = new TestMessage()
  {
  SingleObject = a123
  };
  Bus.Publish(msg,msg1);
}
NServiceBus is able to publish string type easily, how about object type?
On my subscriber's end,
internal void ShowMessage(TestMessage message)
{
  this.Dispatcher.VerifyAccess();
  string receivedString = message.Text;
  object receivedObject = message.SingleObject;
  this.Messages.Insert(0, message);
}
I debug above through, receivedString has "Testing NSB Publish", but receivedObject is always null. How do I receive object at this subscribe's side?
What is the workaround to solve this?
thanks.
Oct 12, 2011 at 3:03 PM

Hi,

A couple of things:

This is the discusssion board for Simple Service Bus ( NOT NServicebus However simple service bus was a fork of NServicebus at some point)

Without the actual stack trace it is rather difficult to debug, but what i am guessing that "object" is simply not serialisable and therefor not handled correctly ( you could enable logging and check )

If you post the actual exception, someone might be able to make more from it..