Getting Started
Architecture
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Message Identity

Component: NServiceBus
NuGet Package: NServiceBus (9.x)

Each message that is dispatched from an Endpoint has a unique identity. NServiceBus generates and stores this value as a header on the message named NServiceBus.MessageId.

Many features take advantage of message identity. For example, the Outbox uses message identity to deduplicate messages and recoverability uses message identity to keep track of how many times the endpoint has tried to process a message.

Specifying message identity

Message identity can be explicitly specified, overriding the default identity provided by NServiceBus.

Specify message identity using the SendOptions class.

var options = new SendOptions();
options.SetMessageId(messageId);

await handlerContext.Send(new SomeMessage(), options);