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.

}<br />

}<br />

}<br />

db_conn.commit();<br />

Dequeue Features<br />

deq_option.setDequeueMode(AQDequeueOption.DEQUEUE_LOCKED);<br />

deq_option.setMessageId(null);<br />

deq_option.setNavigationMode(<br />

AQDequeueOption.NAVIGATION_NEXT_MESSAGE);<br />

}<br />

catch (AQException aqex)<br />

{<br />

new_orders = false;<br />

System.out.println("--- No more booked orders ----");<br />

System.out.println("Exception-1: " + aqex);<br />

}<br />

}<br />

catch (Exception ex)<br />

{<br />

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

}<br />

Optimization of Waiting for Arrival of Messages<br />

AQ allows applications to block on one or more queues waiting for the arrival of<br />

either a newly enqueued message or for a message that becomes ready. You can use<br />

the DEQUEUE operation to wait for the arrival of a message in a queue (see<br />

"Dequeuing a Message" on page 11-44) or the LISTEN operation to wait for the<br />

arrival of a message in more than one queue (see "Listening to One or More<br />

Single-Consumer Queues" on page 11-23.<br />

When the blocking DEQUEUE call returns, it returns the message properties and the<br />

message payload. By contrast, when the blocking LISTEN call returns, it discloses<br />

only the name of the queue where a message has arrived. A subsequent DEQUEUE<br />

operation is needed to dequeue the message.<br />

Applications can optionally specify a timeout of zero or more seconds to indicate<br />

the time that AQ must wait for the arrival of a message. The default is to wait<br />

forever until a message arrives in the queue. This optimization is important in two<br />

ways. It removes the burden of continually polling for messages from the<br />

application. And it saves CPU and network resource because the application<br />

A Sample Application Using AQ 8-75

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

Saved successfully!

Ooh no, something went wrong!