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.

General Features of <strong>Advanced</strong> <strong>Queuing</strong><br />

See also: <strong>Oracle</strong>9i Real Application Clusters Setup and Configuration<br />

Scenario<br />

In the BooksOnLine example, operations on the new_orders_queue and<br />

booked_order_queue at the order entry (OE) site can be made faster if the two<br />

queues are associated with different instances. This is done by creating the queues<br />

in different queue tables and specifying different affinities for the queue tables in<br />

the create_queue_table() command.<br />

In the example, the queue table OE_orders_sqtab stores queue new_orders_<br />

queue and the primary and secondary are instances 1 and 2 respectively. Queue<br />

table OE_orders_mqtab stores queue booked_order_queue and the primary<br />

and secondary are instances 2 and 1 respectively. The objective is to let instances 1<br />

and 2 manage the two queues in parallel. By default, only one instance is available,<br />

in which case the owner instances of both queue tables will be set to instance 1.<br />

However, if Real Application Clusters are set up correctly and both instances 1 and<br />

2 are available, then queue table OE_orders_sqtab will be owned by instance 1<br />

and the other queue table will be owned by instance 2. The primary and secondary<br />

instance specification of a queue table can be changed dynamically using the<br />

alter_queue_table() command as shown in the following example. Information<br />

about the primary, secondary and owner instance of a queue table can be obtained<br />

by querying the view USER_QUEUE_TABLES (see "Selecting Queue Tables in User<br />

Schema" on page 10-21 in "Administrative Interface: Views").<br />

Note: Queue names and queue table names are converted to<br />

upper case. Mixed case (upper and lower case together) is not<br />

supported for queue names and queue table names.<br />

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

/* Create queue tables, queues for OE */<br />

CONNECT OE/OE;<br />

EXECUTE dbms_aqadm.create_queue_table( \<br />

queue_table => ’OE_orders_sqtab’,\<br />

comment => ’Order Entry Single-Consumer Orders queue table’,\<br />

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

compatible => ’8.1’,\<br />

primary_instance => 1,\<br />

secondary_instance => 2);<br />

A Sample Application Using AQ 8-31

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

Saved successfully!

Ooh no, something went wrong!