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.

General Features of JMS<br />

Example Scenario and Code<br />

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

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

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

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

CreateQueueTable() command.<br />

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

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

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

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

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

this case the owner instances of both queue tables will be set to instance1. However,<br />

if <strong>Oracle</strong> Real Application Clusters are set up correctly and both instances 1 and 2<br />

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

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 alter_<br />

queue_table() command as shown in the example that follows. Information about<br />

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

querying the view USER_QUEUE_TABLES. See "Selecting Queue Tables in User<br />

Schema" in Chapter 10, "Administrative Interface: Views".<br />

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

/* createing a queue table to hold queues */<br />

qt_prop = new AQQueueTableProperty("SYS.AQ$_JMS_OBJECT_MESSAGE");<br />

qt_prop.setPrimaryInstance(1);<br />

qt_prop.setSecondaryInstance(2);<br />

q_table = createQueueTable("OE", "OE_orders_sqtab", qt_prop);<br />

/* creating a queue table to hold topics */<br />

qt1_prop = new AQQueueTableProperty("SYS.AQ$_JMS_OBJECT_MESSAGE");<br />

qt1_prop.setMultiConsumer(TRUE);<br />

qt1_prop.setPrimaryInstance(2);<br />

qt1_prop.setSecondaryInstance(1);<br />

q_table1 = createQueueTable("OE", "OE_orders_mqtab", qt1_prop);<br />

dest_prop = new AQjmsDestinationProperty();<br />

queue = ((AQjmsSession)q_sess).createQueue(q_table. "OE_neworders_que",<br />

dest_prop);<br />

dest_prop1 = new AQjmsDestinationProperty();<br />

topic = ((AQjmsSession)q_sess).createTopic(q_table1, "OE_bookedorders_topic",<br />

dest_prop1);<br />

12-20 <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!