RabbitMq message without message-id

My scenario is as follows:

  1. I am receiving a message in my RMQ queue through an upstream federation from an external source. They write to their RMQ exchange without NServiceBus and therefore the message does not come with a message-id header
  2. When NSB picks up this message from my queue, it rejects it saying it needs a message-id

Is there any way for me to inject logic for this endpoint to create a message-id if one does not exist?

See: RabbitMQ native integration • RabbitMQ Transport • Particular Docs

var transport = endpointConfiguration.UseTransport<RabbitMQTransport>();
    customIdStrategy: deliveryArgs =>
        var headers = deliveryArgs.BasicProperties.Headers;
        return headers["MyCustomId"].ToString();

As noted:

It is extremely important that the custom strategy is deterministic (it returns the same value when invoked multiple times for the same message), and that no two messages are assigned the same value.

1 Like