Since batched dispatch isn't available for Versions 5 and below it is necessary to pay more attention to the ordering of outgoing operations when using transports other than MSMQ and SQLServer since they lack support for cross queue transactions. For those transports messages will be dispatched immediately to the transport as soon as the call to
. completes. This means that there is a risk of "ghost" message being emitted if all database operations are not performed prior to bus operations. One example would to do a
. event before calling
DB. since that would cause the
OrderPlaced event to sent even if the order could not be stored in the database.
To avoid ghost messages there are the following options:
- Ensure to make send/publish messages after all storage operations have completed. This would have to be enforced in code reviews and can be hard to detect when there are multiple message handlers for the same message. See message handler ordering for more details on how to control make sure handlers are called in a deterministic way.
- Turn on the Outbox feature on since that essentially will make sure that outgoing operations are not dispatched until all handlers have completed successfully. Even using the InMemory storage for the outbox will provide this type of delayed dispatch.
- Switch to either the MSMQ Transport or SqlServer Transport.