09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Dequeue Features<br />

If a message is browsed, it remains available for further processing. Similarly if a<br />

message is locked, it remains available for further processing after the lock is<br />

released by performing a transaction commit or rollback. After a message is<br />

consumed, using either of the remove modes, it is no longer available for dequeue<br />

requests.<br />

When a message is dequeued using REMOVE_NODATA mode, the payload of the<br />

message is not retrieved. This mode can be useful when the user has already<br />

examined the message payload, possibly by means of a previous BROWSE dequeue.<br />

In this way, you can avoid the overhead of payload retrieval that can be substantial<br />

for large payloads<br />

A message is retained in the queue table after it has been consumed only if a<br />

retention time is specified for a queue. Messages cannot be retained in exception<br />

queues (refer to the section on exceptions for further information). Removing a<br />

message with no data is generally used if the payload is known (from a previous<br />

browse/locked mode dequeue call), or the message will not be used.<br />

Note that after a message has been browsed, there is no guarantee that the message<br />

can be dequeued again since a dequeue call from a concurrent user might have<br />

removed the message. To prevent a viewed message from being dequeued by a<br />

concurrent user, you should view the message in the locked mode.<br />

In general, use care while using the browse mode. The dequeue position is<br />

automatically changed to the beginning of the queue if a nonzero wait time is<br />

specified and the navigating position reaches the end of the queue. Hence repeating<br />

a dequeue call in the browse mode with the "next message" navigation option and a<br />

nonzero wait time can dequeue the same message over and over again. We<br />

recommend that you use a nonzero wait time for the first dequeue call on a queue<br />

in a session, and then use a zero wait time with the next message navigation option<br />

for subsequent dequeue calls. If a dequeue call gets an "end of queue" error<br />

message, the dequeue position can be explicitly set by the dequeue call to the<br />

beginning of the queue using the "first message" navigation option, following which<br />

the messages in the queue can be browsed again.<br />

Scenario<br />

In the following scenario from the BooksOnLine example, international orders<br />

destined to Mexico and Canada are to be processed separately due to trade policies<br />

and carrier discounts. Hence, a message is viewed in the locked mode (so no other<br />

concurrent user removes the message) and the customer country (message payload)<br />

is checked. If the customer country is Mexico or Canada, the message is consumed<br />

(deleted from the queue) using REMOVE_NODATA (since the payload is already<br />

known). Otherwise, the lock on the message is released by the commit call. Note<br />

8-70 <strong>Oracle</strong>9i Application Developer’s Guide - <strong>Advanced</strong> <strong>Queuing</strong>

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

Saved successfully!

Ooh no, something went wrong!