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.

Enqueue Features<br />

list may or may not be subscribers for the queue. It is an error if the queue does not<br />

have any subscribers and the enqueue does not specify a recipient list (see<br />

"Enqueuing a Message" on page 11-4 in Chapter 11, "Operational Interface: Basic<br />

Operations").<br />

Priority and Ordering of Messages<br />

The message ordering dictates the order that messages are dequeued from a queue.<br />

The ordering method for a queue is specified when a queue table is created (see<br />

"Creating a Queue Table" on page 9-4 in Chapter 9, "Administrative Interface").<br />

Priority ordering of messages is achieved by specifying priority, enqueue time as<br />

the sort order for the message. If priority ordering is chosen, each message will be<br />

assigned a priority at enqueue time by the enqueuer. At dequeue time, the messages<br />

will be dequeued in the order of the priorities assigned. If two messages have the<br />

same priority, the order in which they are dequeued is determined by the enqueue<br />

time. A first-in, first-out (FIFO) priority queue can also be created by specifying the<br />

enqueue time, priority as the sort order of the messages.<br />

Scenario<br />

In the BooksOnLine application, a customer can request:<br />

FedEx shipping (priority 1),<br />

Priority air shipping (priority 2). or<br />

Regular ground shipping (priority 3).<br />

<br />

The Order Entry application uses a priority queue to store booked orders. Booked<br />

orders are propagated to the regional booked orders queues. At each region, orders<br />

in these regional booked orders queues are processed in the order of the shipping<br />

priorities.<br />

The following calls create the priority queues for the Order Entry application.<br />

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

/* Create a priority queue table for OE: */<br />

EXECUTE dbms_aqadm.create_queue_table( \<br />

queue_table => 'OE_orders_pr_mqtab', \<br />

sort_list =>'priority,enq_time', \<br />

comment => 'Order Entry Priority \<br />

multiple_consumers<br />

MultiConsumer Orders queue table',\<br />

=> TRUE, \<br />

queue_payload_type => 'BOLADM.order_typ', \<br />

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