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.

Enqueue Features<br />

}<br />

Time Specification: Expiration<br />

db_conn.commit();<br />

}<br />

catch (Exception ex)<br />

{<br />

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

}<br />

Messages can be enqueued with an expiration that specifies the interval of time the<br />

message is available for dequeuing. Note that expiration processing requires that<br />

the queue monitor be running. The producer can also specify the time when a<br />

message expires, at which time the message is moved to an exception queue.<br />

Scenario<br />

In the BooksOnLine application, expiration 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 queue. If the shipping policy is that<br />

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

the back order queue with an expiration of 1 week. In this case, any back orders that<br />

are not processed within one week are moved to the exception queue with the<br />

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

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

PL/SQL (DBMS_AQADM Package): Example Code<br />

CONNECT BOLADM/BOLADM<br />

/* Req-enqueue a back order into a back order queue and set a delay of 7 days;<br />

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

exception queue: */<br />

CREATE OR REPLACE PROCEDURE requeue_back_order(sale_region varchar2,<br />

backorder order_typ)<br />

AS<br />

back_order_queue_name VARCHAR2(62);<br />

enqopt dbms_aq.enqueue_options_t;<br />

msgprop dbms_aq.message_properties_t;<br />

enq_msgid RAW(16);<br />

BEGIN<br />

/* Look up a back order queue based the the region by means of a directory<br />

service: */<br />

IF sale_region = 'WEST' THEN<br />

8-48 <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!