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
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?
var transport = endpointConfiguration.UseTransport<RabbitMQTransport>();
transport.CustomMessageIdStrategy(
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.