09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

JMS Message Producer Features<br />

Example Scenario<br />

In the BooksOnLine application, TimeToLive can be used to control the amount of<br />

time that is allowed to process a back order. The shipping application places orders<br />

for books that are not available on a back order topic. If the shipping policy is that<br />

all back orders must be shipped within a week, then messages can be published<br />

into the back order topic with an expiration of one week. In this case, any back<br />

orders that are not processed within one week are moved to the exception topic<br />

with the message state set to EXPIRED. This can be used to flag any orders that<br />

have not been shipped according to the back order shipping policy.<br />

Example Code<br />

/* Re-enqueue a back order into a back_order Topic and set a timeToLive of<br />

7 days;<br />

All back orders must be processed in 7 days or they are moved to the<br />

exception queue */<br />

public static void requeue_back_order(TopicSession jms_session,<br />

String sale_region, BolOrder back_order)<br />

{<br />

Topic back_order_topic;<br />

ObjectMessage obj_message;<br />

TopicPublisher tpub;<br />

long timetolive;<br />

try<br />

{<br />

/* Look up a back order topic based on the region */<br />

if(sale_region.equals("WEST"))<br />

{<br />

back_order_topic = ((AQjmsSession)jms_session).getTopic("WS",<br />

"WS_backorders_topic");<br />

}<br />

else if(sale_region.equals("EAST"))<br />

{<br />

back_order_topic = ((AQjmsSession)jms_session).getTopic("ES",<br />

"ES_backorders_topic");<br />

}<br />

else<br />

{<br />

back_order_topic = ((AQjmsSession)jms_session).getTopic("OS",<br />

"OS_backorders_topic");<br />

}<br />

obj_message = jms_session.createObjectMessage();<br />

Creating Applications Using JMS 12-61

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!