Messages produced by a single producer to a single destination
will be seen by a consumer in that destination in the same order as they were
produced. However, certain events, such as system failures, can disrupt this
order. Message ordering allows you to prevent this order being changed.
Message reordering can be avoided if the following rules are applied:
- All the messages produced have the same priority.
- All the messages produced have the same reliability and that reliability
is greater than best effort nonpersistent (for more information
about reliability levels see Message reliability levels).
Note that if messages are produced with a reliability of anything less than assured
persistent, it is possible for sequences of messages to be redelivered
after a failure, however their underlying order will be maintained. For example,
messages may arrive in the following sequence: 1, 2, 3, 2, 3, 4.
- The producer is single threaded (as supported by the JMS API).
- If the destination is a queue, it is not assigned
to a cluster bus member with more than one messaging engine, or the producer
is bound to a single queue point (see Workload sharing with queue destinations).
- The destination has no exception destination defined. Otherwise, under
certain failure scenarios, some messages might be delivered to the exception
destination, then these messages might be processed out of order.
- The destination is in the same bus as the producer, or the link between
buses is configured to have no exception destination. If the destination and
the producer are in different buses, the route from the producer's bus to
the destination's bus must not be altered.
- The consumer does not deliberately alter the order of messages retrieved,
for example by changing its selector.
- If the destination is a queue, only one consumer
is consuming from it. If the consumer cannot be guaranteed to be connected
to the messaging engine that owns the queue point of the queue, the queue
must be configured to be Receive exclusive. The consumer
must not gather messages from multiple queue points (see Workload sharing with queue destinations).
- If the destination is a topic space and the consumer's subscription is
nondurable, ordering is not guaranteed across separate instances of the subscription.
- If the destination is a topic space the consumer's subscription is not
created with the Share Durable Subscriptions property
set to permit sharing.
These rules assure correct ordering of the messages consumed by a single
consumer, however they do not guarantee that the consumer will receive all
messages produced by the producer. Whether the consumer receives all messages
can be affected for a number reasons, including the reliability of the messages
and the consumer's selection criteria.
These rules also assure the order of messages produced by a single producer.
When a consumer consumes messages from different producers that follow these
rules, the messages might be interleaved.
A destination can be configured to have some of the
listed restrictions enforced automatically and additional restrictions applied.
For further information, see Strict message ordering for bus destinations.