Java Reference
In-Depth Information
// Add content to message
producer.send(outMessage);
// Display message contentssession.commit();
4.
The vendor receives the suppliers' replies from its confirmation queue and updates
the state of the order. Messages are processed by an asynchronous message listen-
er; this step shows the use of JMS transactions with a message listener.
MapMessage component = (MapMessage) message;
...
orderNumber = component.getInt("VendorOrderNumber");
Order order =
Order.getOrder(orderNumber).processSubOrder(component);
session.commit();
5.
When all outstanding replies are processed for a given order, the vendor message
listener sends a message notifying the retailer whether it can fulfill the order.
Queue replyQueue = (Queue) order.order.getJMSReplyTo();
MessageProducer producer = session.createProducer(replyQueue);
MapMessage retailerConfirmMessage = session.createMapMessage();
// Format the message
producer.send(retailerConfirmMessage);
session.commit();
6.
The retailer receives the message from the vendor:
inMessage = (MapMessage) orderConfirmReceiver.receive();
Figure 21-2
illustrates these steps.