Message Processing According to the JMS Specification Message Processing with Unit-of-Order

10 Using Message Unit-of-Order 10-1 10 Using Message Unit-of-Order The following sections describe how to use Message Unit-of-Order to provide strict message ordering when using WebLogic JMS: ■ Section 10.1, What Is Message Unit-Of-Order? ■ Section 10.2, Understanding Message Processing with Unit-of-Order ■ Section 10.3, Message Unit-of-Order Case Study ■ Section 10.4, How to Create a Unit-of-Order ■ Section 10.5, Message Unit-of-Order Advanced Topics ■ Section 10.6, Limitations of Message Unit-of-Order 10.1 What Is Message Unit-Of-Order? Message Unit-of-Order is a WebLogic Server value-added feature that enables a stand-alone message producer, or a group of producers acting as one, to group messages into a single unit with respect to the processing order. This single unit is called a Unit-of-Order and requires that all messages from that unit be processed sequentially in the order they were created.

10.2 Understanding Message Processing with Unit-of-Order

The following sections compare message processing as described by the JMS specification with message processing enhanced by using WebLogic Servers Message Unit-of-Order feature. ■ Section 10.2.1, Message Processing According to the JMS Specification ■ Section 10.2.2, Message Processing with Unit-of-Order ■ Section 10.2.3, Message Delivery with Unit-of-Order

10.2.1 Message Processing According to the JMS Specification

While the Java Message Service Specification, at http:www.java.sun.comproductsjmsdocs.html , provides an ordered message delivery, it does so in a very strict sense. It defines order between a single instance of a producer and a single instance of a consumer, but does not take into account the following common situations: ■ Many consumers on one queue. See Chapter 9, Using Distributed Destinations. 10-2 Programming JMS for Oracle WebLogic Server ■ Multiple producers within a single application acting as a single producer. See Chapter 9, Using Distributed Destinations. ■ Message recoveries or transaction rollbacks where other messages from the same producer can be delivered to another consumer for processing. See Section 10.5.1, What Happens When a Message Is Delayed During Processing? . ■ Use of filters and destination sort keys. See Section 10.5, Message Unit-of-Order Advanced Topics.

10.2.2 Message Processing with Unit-of-Order

The WebLogic Server Unit-of-Order feature enables a message producer or group of message producers acting as one, to group messages into a single unit that is processed sequentially in the order the messages were created. The message processing of a single message is complete when a message is acknowledged, committed, recovered, or rolled back. Until message processing for a message is complete, the remaining unprocessed messages for that Unit-of-Order are blocked. This section provides information on rules for JMS acknowledgement modes, described at http:www.java.sun.comproductsjmsdocs.html , when using Message Unit-of-Order: ■ No messages from a Unit-of-Order are processed in parallel when the acknowledgement mode is CLIENT_ACKNOWLEDGE, AUTO_ACKNOWLEDGE, or DUPS_OK_ACKNOWLEDGE. ■ When the consumer is closed, the current message processing is completed, regardless of the sessions acknowledge mode. ■ CLIENT_ACKNOWLEDGE – The application calling Message.acknowledge and Session.recover indicate which messages are completely processed in the Unit-of-Order. ■ AUTO_ACKNOWLEDGE – The session automatically acknowledges a clients receipt of a message when it has either successfully returned from a call to receive or when the MessageListener that was called returns successfully. – Asynchronous mode: Successful completion or exception of onMessagemsg indicates when a message is completely processed. – Synchronous mode: For a given consumer, such as consumer A, consumerA.receive is completed when one of the following occurs: consumerA.receive, consumerA.setMessageListener, or consumerA.close. ■ DUPS_OK_ACKNOWLEDGE – The session automatically acknowledges a clients receipt of a message when it has either successfully returned from a call to receive or when the MessageListener that was called returns successfully. – Asynchronous mode: Successful completion or exception of onMessagemsg indicates when a message is completely processed. – Synchronous mode: For a given consumer, such as consumer A, consumerA.receive is completed when one of the following occurs: consumerA.receive, consumerA.setMessageListener, or consumerA.close. ■ NO_ACKNOWLEDGE – The session provides no order processing guarantees. Messages can be processed in parallel to different available consumers. Using Message Unit-of-Order 10-3

10.2.3 Message Delivery with Unit-of-Order