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.

Time Specification - Delay<br />

}<br />

"OE_bookedorders_topic");<br />

/* Create the topic publisher */<br />

tpub = jms_session.createPublisher(topic);<br />

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

obj_message.setObject(order);<br />

/* Send message - specify priority */<br />

tpub.publish(topic, obj_message, DeliveryMode.PERSISTENT,<br />

ship_priority,0);<br />

jms_session.commit();<br />

}<br />

catch (Exception ex)<br />

{<br />

System.out.println("Exception ex: " + ex);<br />

}<br />

JMS Message Producer Features<br />

Messages can be sent/published to a queue/topic with Delay. The delay represents<br />

a time interval after which the message becomes available to the Message<br />

Consumer. A message specified with a delay is in a waiting state until the delay<br />

expires and the message becomes available. Delay for a message is specified as<br />

message property (JMS_<strong>Oracle</strong>Delay). This property is not specified in the JMS<br />

standard. It is an AQ extension to JMS message properties.<br />

Delay processing requires the AQ background process, the queue monitor to be<br />

started. Note also that receiving by msgid overrides the delay specification.<br />

Example Scenario and Code<br />

In the BooksOnLine application, delay can be used to implement deferred billing.<br />

The billing application defines a queue in which shipped orders that are not billed<br />

immediately are placed with a delay. For example, a certain class of customer<br />

accounts, such as corporate customers, may not be billed for 15 days. The billing<br />

application dequeues incoming shipped order messages (from the shipped orders<br />

queue) and if the order is for a corporate customer, this order is enqueued into a<br />

deferred billing queue with a delay. Delay works similarly for publish, though a<br />

scenario has not been provided.<br />

public static void defer_billing(QueueSession jms_session,<br />

Creating Applications Using JMS 12-59

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

Saved successfully!

Ooh no, something went wrong!