I am running into a rather strange issue. When I publish message the constructor is initialized with proper GUID value, but when Breakpoint is invoked again when message arrives the value of GUID is always {00000000-0000-0000-0000-000000000000}. For some reason MassTransit is not invoking class with proper values. I verified the message on RabbitMQ subscription queue and the message indeed has the proper GUID value when it gets published.
//Message
public class OrderCreated
{
private readonly Guid _aggregateId;
public OrderCreated(Guid aggregatedId)
{
_aggregateId = aggregatedId; //Breakpoint
}
public Guid AggregateId
{
get { return _aggregateId; }
}
}
//Handler
public class OrderCreatedEventHandler : IConsumer<OrderCreated>
{
public async Task Consume(ConsumeContext<OrderCreated> context)
{
await Task.Factory.StartNew(() =>
{
Console.WriteLine(context.Message.AggregateId);
});
}
}
//Portion of bus configuration code section
cfg.ReceiveEndpoint(host,"my_consumer",
c =>
{
c.Consumer<OrderCreatedEventHandler>();
});
//Left bus initialization code intentionally for clarity
var _bus = _container.GetInstance<IBusControl>();
_bus.Start();
var order = new OrderCreated(Guid.NewGuid());
_bus.Publish(order);
_bus.Stop();