The below post gives a good understanding of need of Unit Of Order with Distributed Destinations and ways to configure the same.
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 (a sub-ordering). This single unit is called a Unit-of-Order (or UOO) and requires that all messages from that unit be processed sequentially in the order they 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 feature works best when a group of messages from a single producer must be processed sequentially.
For example, producer A sends messages X, Y, and Z in a unit-of-order. An MDB picks up message X and processes it. Until the MDB instance commits the transaction, message Y and Z remain on the queue. Only when the MDB commits message X does message Y get processed, and so on.
1. A distributed destination pre configured.
You can refer the below link to do so.
There are two ways to create a unit-of-order
Programmatically: WebLogic supplies a
weblogic.jms.extensions.WLMessageProducer class, which implements the
It has two methods:
getUnitOfOrder(): To get the name of the current Unit Of Order.
setUnitOfOrder(): To set the name of the Current Unit Of Order.
queue = (Queue)(ctx.lookup(destName)); qsender = (WLMessageProducer) qs.createProducer(queue); qsender.setUnitOfOrder(); uooname = qsender.getUnitOfOrder(); System.out.println("Using UnitOfOrder :" + uooname);
Steps to implement Unit Of Order feature with Distributed Destination:
NOTE: You can configure the Unit Of Order name at two levels.
1 . Connection Factory
2. Distributed Destination.
1: Unit Of Order at Connection Factory level:
There are two types of Unit Of Order naming that is done.
User Defined Unit Of Order: You can configure the Connection Factories to use User-Defined Unit Of Order name. All producers created from such a connection factory have Unit-of-Order enabled.
a. Login into the admin console, navigate to the ConnectionFactory –> Click on the DefaultDelivery subtab –> Select the type of Unit Of Order name that you would like to configure.
b. If you are selecting User Defined Unit Of Order, you need to specify the value for “User-generated Unit-of-Order Name:” attribute.
System Defined: If you want you can configure the system defined Unit Of Order name for the Connection Factory for each sessions.
2. Unit Of Order at the Distributed Destination level:
a. Navigate to the Distributed Destination –> General –> Advanced properties.
Enable the “Auto-generate Unit Of Order Name ” attribute.
Specify the routing algorithm as well. By default it would be Hash.
Hash, indicates that a message producer computes the member destination from the
hashCode of the unit-of-order.
PathService indicates that the configured Path Service determines the member destination.
This completes the JMS Unit Of Order configuration.
This typical Unit Of Order configuration would look like below in the config/jms/<systemModule>-jms.xml file.
<uniform-distributed-queue name="DistributedQueue-1"> <sub-deployment-name>subManaged</sub-deployment-name> <default-targeting-enabled>false</default-targeting-enabled> <attach-sender>supports</attach-sender> <production-paused-at-startup>false</production-paused-at-startup> <insertion-paused-at-startup>false</insertion-paused-at-startup> <consumption-paused-at-startup>false</consumption-paused-at-startup> <jndi-name>DistQueue</jndi-name> <default-unit-of-order>true</default-unit-of-order> <saf-export-policy>All</saf-export-policy> <messaging-performance-preference>25</messaging-performance-preference> <unit-of-work-handling-policy>PassThrough</unit-of-work-handling-policy> <incomplete-work-expiration-time>-1</incomplete-work-expiration-time> <load-balancing-policy>Round-Robin</load-balancing-policy> <unit-of-order-routing>Hash</unit-of-order-routing> <forward-delay>-1</forward-delay> <reset-delivery-count-on-forward>true</reset-delivery-count-on-forward> </uniform-distributed-queue>
Wonders Team. 🙂