Using Unit-of-Order with JMS Message Management Using Unit-of-Order with WebLogic Store-and-Forward

10-10 Programming JMS for Oracle WebLogic Server

10.5.5 Using Unit-of-Order with Topics

Assigning a Unit-of-Order does not prohibit parallel processing of a message by two subscribers on the same topic. Since individual subscribers for a topic have their own destination and message list, similar to a queue with one consumer, messages are processed by all subscribers according to the Unit-of-Order assigned at the time of production.

10.5.5.1 Unit-of-Order and Distributed Topics

The routing of messages between physical topics can affect Unit-of-Order if an application directly sends to a member of a distributed topic. To ensure correct order of processing, the application must ensure the messages are sent via the logical distributed topic that is, the destination is obtained using the JNDI name of the distributed topic. WebLogic Server then ensures messages with the same Unit-of-Order take the same path to the distributed topic member.

10.5.5.2 Unit-of-Order, Topics, and Message Driven Beans

The WebLogic Server message driven bean implementation goes beyond the requirements of the EJB and JMS specifications to provide parallel processing of an incoming message stream for a single topic subscription and JMS session. This parallel processing does not take Unit-of-Order into account, so care is required to ensure that the processing is still ordered correctly. There are two ways to achieve this – either process each message in its own JTA transaction, or disable parallel processing by setting the pool size to one. When using Unit-of-Order with topics and message driven beans, you must either: ■ Section 10.5.5.2.1, Use JTA Transactions or ■ Section 10.5.5.2.2, Set Pools Size to One Start by configuring MDBs to Section 10.5.5.2.1, Use JTA Transactions. In the unlikely event that the transaction overhead is unacceptable, switch to Section 10.5.5.2.2, Set Pools Size to One.

10.5.5.2.1 Use JTA Transactions The simplest approach is to use JTA transactions. It has

a processing overhead, but is usually low as WebLogic Server has a highly optimized transaction engine and the application benefits from parallel processing of messages that have different Units-of-Order. The JTA transaction may be of benefit for some application use cases. For example, where it is necessary to ensure atomic interaction with other operations such as sending JMS messages, or updating a database.

10.5.5.2.2 Set Pools Size to One Setting the pool size to one allows more efficient,

non-transactional messaging to be used, but has a drastic effect on parallelism.

10.5.6 Using Unit-of-Order with JMS Message Management

JMS message management allows a JMS administrator to move and delete most messages in a running JMS Server. This allows an administrator to violate the delivery rules specified in Section 10.2.3, Message Delivery with Unit-of-Order. If messages A, B, C, and D are produced and sent to destination D1 and belong to Unit-of-Order foo, consider the following: ■ Moving messages C and D to destination D2 may allow parallel processing of messages from both destinations. Using Message Unit-of-Order 10-11 ■ Moving messages B and C to destination D2 may allow parallel processing of message A and messages B and C. After message A is processed, message D is deliverable. For applications that depend on maintaining message order, a best practice is to move all of the messages in a Unit-of-Order as a single group. To ensure Unit-of-Order delivery rules are maintained, use the following steps: 1. Pause the source destination and the target destination. 2. Select all of the messages with the Unit-of-Order you would like to move. 3. Move the selected messages to the target destination. If necessary, sort them according to the order that you want them processed. 4. Resume the source and target destinations. For more information, see Troubleshooting WebLogic JMS in Configuring and Managing JMS for Oracle WebLogic Server.

10.5.7 Using Unit-of-Order with WebLogic Store-and-Forward

WebLogic Store-and-Forward supports Message Unit-of-Order. For example, a Store-and-Forward producer sends messages with a Unit-of-Order named Foo. If the producer disconnects and reconnects through a different connection, the producer creates another Unit-of-Order with the name Foo and continues sending messages. All messages sent before and after the reconnect are directed through the same Store-and-Forward agent. See Configuring and Managing Store-and-Forward for Oracle WebLogic Server.

10.5.8 Using Unit-of-Order with WebLogic Messaging Bridge