An implementation of the
IIdempotenceService interface is responsible for ensuring that message remain idempotent on a technical level. This means that if, by some edge case, a message happens to be duplicated then only one instance of the message will be processed. This is done by keeping track of which message ids have been processed.
In addition to this the idempotence service also defers message sending when message are sent (or published) within a transaction.
ProcessingStatus ProcessingStatus(TransportMessage transportMessage);
This method must return the
ProcessingStatus of the given
ProcessingStatus.Ignoreif the message has been processed completely and also if it currently being processed by another consumer.
ProcessingStatus.MessageHandledif the message has already been handled. There may be deferred messages that need to be sent.
ProcessingStatus.Assignedif this message is assigned for initial processing.
void ProcessingCompleted(TransportMessage transportMessage);
Marks the message as having being processed successfully.
void AddDeferredMessage(TransportMessage processingTransportMessage, Stream deferredTransportMessageStream);
deferredTransportMessageStream against the given
processingTransportMessage in order for the service bus to perform the actual dispatching of the deferred message after the messae ahs been handled.
IEnumerable<Stream> GetDeferredMessages(TransportMessage transportMessage);
Returns all the streams that were sent during the handling of the given
void DeferredMessageSent(TransportMessage processingTransportMessage, TransportMessage deferredTransportMessage);
This method should remove the entry associated with the
deferredTransportMessage as it has been dispatched.
void MessageHandled(TransportMessage transportMessage);
Once the message has been successfully handled this method is called to mark the message as handled in the store.