Strict message ordering for bus destinations
If message order must be maintained in all circumstances, a destination can be configured so that the order of messages is preserved much more rigorously than for a normal destination.
In general, messages produced by a single producer to a single destination are seen by a consumer to that destination in the same order as they are produced. However, there are certain topologies and events, such as system failures, that can change the order of messages (see Message ordering for details). If strict message order is essential then we can configure a destination to preserve the order of the messages in a much more rigorous manner. Using strict message ordering, in conjunction with restricted topologies (as described later in this section), maintains message order in all circumstances.
Restrictions that are enforced automatically
When you include a strictly ordered destination in the system, certain restrictions are automatically enforced at run time. These restrictions affect the way that applications can interact with the destination to ensure strict message order, ensure that you fully understand each of the following restrictions prior to configuring a destination to be totally ordered.
- Concurrent consumers are prevented from attaching to an ordered destination. Having more than one consumer consuming from a destination can result in messages being consumed out of order. So, for an ordered queue destination, and any subscription on an ordered topic space, one consumer at most can attach at any one time. This is equivalent to setting "receive exclusive" to true on a queue destination and "Share durable subscriptions" to "never shared" on a JMS topic connection factory, and warnings are generated in the system log to indicate if these options have been overridden. The attached consumer is also restricted to a single transaction at any one time (this is the normal behavior for many messaging interfaces so should not affect many users, for example, JMS).
- Partially consumed messages prevent subsequent messages from being consumed. For standard destinations (that is, destinations without the strict message ordering option enabled), messages that have been partially consumed from the destination (for example, received within a transaction that is yet to be committed) might be skipped over by a consumer to allow processing of messages to continue past previously consumed messages that are yet to be committed. This can disrupt message order. For an ordered destination, such messages are not skipped by a consumer, instead the consumer is blocked until the message has either been totally removed (for example, the uncommitted transaction is committed) or replaced (for example, the uncommitted transaction is rolled back). This situation would occur if a previously attached consumer fails to commit a transaction that was used to consume messages from the destination, or if a transactional resource becomes temporarily unavailable during the commit of a transaction. If the resource is permanently unavailable, see Resolve indoubt transactions for information on resolving these transactions.
- Concurrent message driven beans (MDBs) are restricted for an ordered destination. The maximum concurrent endpoints and maximum batch size settings of any MDB deployed on an ordered destination are overridden to be one. For more information, see JMS activation specification [Settings]. This ensures the ordered processing of messages by the MDB. When the system overrides this property at run time, a warning is generated in the system log.
- Concurrent mediations are restricted for an ordered destination. The allow concurrent mediation setting of any mediation on an ordered destination is overridden to be false. For more information, see Concurrent mediations. This ensures the ordered processing of messages by the mediation. When the system overrides this property at run time, a warning is generated in the system log.
- If Automatically stop endpoints on repeated message failure is enabled then the Sequential failed message threshold is overridden to 1.
- Effect of enabling Maintain Strict Message Order on an existing topic destination. If the strict message ordering is enabled on an existing topic destination, any existing durable subscriptions along with the messages associated become invalid. When the strict message ordering is enabled and the environment is restarted, the existing durable subscriptions are deleted and re-created; the messages associated with the durable subscriptions are also deleted.
Additional restrictions that might affect message ordering
Even with strict message order enabled on a destination the following restrictions are not automatically enforced, but they could affect message ordering and therefore should be understood:
- If a destination has an exception destination configured, it is possible for messages intended for that destination to be delivered to the exception destination under error conditions such as a message reaching its maximum failed delivery limit. This redirecting of messages could be regarded as changing the order of messages, and if that is so, then the destination should set the exception destination to "none". Note that setting the exception destination to none results in messages that would otherwise be moved to the exception destination remaining on the destination.
- Change the topology of a service integration bus can affect message order. For example, deleting and recreating an ordered destination must be seen as two distinct destinations and therefore order cannot be guaranteed across both destinations.
- Introducing or removing a mediation can affect message order. If a mediation is introduced to a destination or is removed from a destination while messages are flowing to and through the destination, message order is not necessarily preserved.
- Mediations can be designed to deliberately affect message order, and therefore changing a mediation can directly affect message order. For example, you could introduce a mediation that reorders messages or routes messages to different destinations.
- Alias destinations and foreign destinations do not have an option to maintain strict message order. In each case, only the underlying destination can be ordered.
- If a queue destination is deployed to a cluster bus member that has more than one messaging engine, which means that the destination has more than one queue point or mediation point, message order cannot be maintained across the destination. Therefore, enabling strict message order on such a destination does not assure message order. Configuring message affinity allows sets of messages to be sent to the same queue point for processing in order by a single consumer. Message affinity has performance implications because the messages are no longer workload balanced across multiple queue points.
Important: The system does not prevent you from using partitioned destinations. It is your responsibility to ensure that partitioned destinations are not used in the system.
- Messages with a reliability of anything other than assured persistent may be lost or duplicated under certain conditions. For more information, see Message reliability levels - JMS delivery mode and service integration quality of service. If this is regarded as disrupting the order of messages, then only assured persistent messages should be used with a strictly ordered destination.
- Ordering of messages is assured within message priority, it should be understood that messages of a different priority can overtake messages of a lower priority.
- Ordering of messages is assured within message reliability, it should be understood that messages of one reliability can overtake messages of a different reliability.
- Although multiple consumers are not allowed to attach to an ordered destination, multiple producers can be used to send messages to ordered destinations. Ordering across multiple producers is not assured as messages appear at the destination in the order that the sending transactions are committed.
- Application code might contain logic that can disrupt message ordering.
Related concepts
Message ordering Workload sharing with queue destinations
Related tasks
Specify whether strict message order is preserved for a bus destination Configure exception destination processing for a link to a foreign bus