MassTransit: Messages with nested MessageData is sending to error queue

Is this a bug report?

Yes

Can you also reproduce the problem with the latest version?

Yes, MT version 6.3.2

Environment

  1. Operating system: Linux
  2. Dotnet version: 3.1.101

Steps to Reproduce

  1. Create a Message with nested MessageData:
public interface MyCustomizedFile
{
    string Name { set; get; }
    MessageData<string> Content { set; get; }
}
public interface MyEventMessage
{
    MyCustomizedFile MyFile { get; set; }
}
  1. Send the event massage including file content.
  2. So the message is not consumed and is sent to error queue.
  3. Send the event massage with null file content.
  4. So the message is consumed normally.

Expected Behavior

I expect the MyEventMessage.MyCustomizedFile.FileContent contains the sent file.

Actual Behavior

The message event is sent normally, but when the nested message data is filled the consumer don’t receive the message.

Reproducible Demo

  1. Clone the repository: https://github.com/rafaelcaviquioli/MassTransitMessageDataTest
  2. Start RabbitMQ: docker-compose up rabbitmq
  3. Run the console app.
  4. The console app is sending two events.
  5. This is the expected log because only the event which has no file content is received:
$ dotnet run
Listening for events, press a key to exit...
Received the event MyEvent with null message data - Doesn't have file value

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 26 (13 by maintainers)

Commits related to this issue

Most upvoted comments

there are no breaking changes you can notice, except you are using parts marked as obsolete

I have an idea of why it’s happening. The failure I see is with initializers and then the convention to store the data. I can reproduce it so I can fix it.

And that works like a charm. 👏 🎉 image

================================================================================
TEST 1
================================================================================
Start - Request message--------------
 Message.TopText=A message WITH NO messageData at the top-level
 Message.Foo.SomeText=Animal world
 Message.Foo.File.Length=4
 Message.Foo.Bars.Count=1
 Message.Foo.Bars[0] - SomeNumber=999, SomeText=It barks, SomeEnum=Dog, SomeDatetime=05/30/2020 11:07:11, File.Length=4
 Message.Bars[0] - SomeNumber=888, SomeText=It meows, SomeEnum=Cat, SomeDatetime=05/31/2020 11:07:11, File.Length=4
End - Request message--------------

----------- Consuming A message WITH NO messageData at the top-level
 Message.Foo.File.Length=4

Start - Response message--------------
 Message.TopText=Message 1 consumed
 Message.File.Length=1000
 Message.DataReceived.Foo.SomeText=Animal world
 Message.DataReceived.File.Length=4
 Message.DataReceived?.Foo?.Bars.Count=1
 Message.DataReceived.Foo.Bars[0] - SomeNumber=999, SomeText=It barks, SomeEnum=Dog, SomeDatetime=05/30/2020 11:07:11, File.Length=4
 Message.DataReceived.Bars[0] - SomeNumber=888, SomeText=It meows, SomeEnum=Cat, SomeDatetime=05/31/2020 11:07:11, File.Length=4
End - Response message--------------

================================================================================
TEST 2
================================================================================
Start - Request message--------------
 Message.TopText=A message WITH messageData at the top-level
 Message.Foo.SomeText=Animal world
 Message.Foo.File.Length=4
 Message.Foo.Bars.Count=1
 Message.Foo.Bars[0] - SomeNumber=999, SomeText=It barks, SomeEnum=Dog, SomeDatetime=05/30/2020 11:07:12, File.Length=4
 Message.Bars[0] - SomeNumber=888, SomeText=It meows, SomeEnum=Cat, SomeDatetime=05/31/2020 11:07:12, File.Length=4
End - Request message--------------

----------- Consuming A message WITH messageData at the top-level

Start - Response message--------------
 Message.TopText=Message 2 consumed
 Message.File.Length=3
 Message.DataReceived.File.Length=19481
 Message.DataReceived.Foo.SomeText=Animal world
 Message.DataReceived.Foo.File.Length=4
 Message.DataReceived.Foo.Bars.Count=1
 Message.DataReceived.Foo.Bars[0] - SomeNumber=999, SomeText=It barks, SomeEnum=Dog, SomeDatetime=05/30/2020 11:07:12, File.Length=4
 Message.DataReceived.Bars[0] - SomeNumber=888, SomeText=It meows, SomeEnum=Cat, SomeDatetime=05/31/2020 11:07:12, File.Length=4
End - Response message--------------

Thank you very much @phatboyg!

Last question: We were upgrading our system from MT v5 to v6. Are there any breaking changes from v6 to v7?

Okay, maybe this time I actually fixed it.

Hi @phatboyg ,

Rafael is my teammate 😃

Here is the repo of my tests https://github.com/tonholis/MTEncTest, as requested in Discord.

As I mentioned, the tests pass but the actual application/service doesn’t work. The response message containing the complex structure with MessageData is not fully populated.