rebus-org / Rebus

:bus: Simple and lean service bus implementation for .NET
https://mookid.dk/category/rebus
Other
2.26k stars 355 forks source link

MessageId not found for Azure ServiceBus message #866

Closed MarcBruins closed 4 years ago

MarcBruins commented 4 years ago

It seems that the required MessageId is not found for my azureservicebus messages. I'm using ServiceBus explorer to create a message which contains a MessageId:

image

As you can see, the MessageId is there. Now when i start my console app i get the following error:

[ERR] Rebus.Retry.PoisonQueues.PoisonQueueErrorHandler (Thread #13): Moving message with ID "<unknown>" to error queue "error"
Rebus.Exceptions.RebusApplicationException: Received message with empty or absent 'rbs2-msg-id' header! All messages must be supplied with an ID . If no ID is present, the message cannot be tracked between delivery attempts, and other stuff would also be much harder to do - therefore, it is a requirement that messages be supplied with an ID.

My configuration looks like this:

        static void Main(string[] args)
        {
            // we have the container in a variable, but you would probably stash it in a static field somewhere
            using (var activator = new BuiltinHandlerActivator())
            {
                Configure.With(activator)
                    .Transport(t => t.UseAzureServiceBus("Endpoint={connectionString}", "testqueue"))
                    .Start();

                Console.WriteLine("Press enter to quit");
                Console.ReadLine();
            }
        }

Am i forgetting something?

Using version Rebus.AzureServiceBus 7.1.0 and Rebus 6.1.0

mookid8000 commented 4 years ago

This is because your message does not have the rbs2-msg-id header.

I don't know how to manually craft messages with Service Bus Explorer, but my guess is that it's possible to provide rbs2-msg-id manually somehow.

The rbs2-msg-id header is the minimal requirement for Rebus to attempt to consume a message. Other headers might also be needed, e.g. if you want Rebus' built-in JSON serializer to deserialize the message, you need to provide information about the content. The serializer should throw some helpful exceptions for everything that it needs. 🙂

I hope you'll make it work. 😁