See: RabbitMQ native integration • RabbitMQ Transport • Particular Docs
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.