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.

JMS Message Consumer Features<br />

NEXT_TRANSACTION sets the position to the first message in the next<br />

<br />

transaction.<br />

Note that the transaction grouping property may be negated if messages are<br />

received in the following ways:<br />

Receive specifying a correlation identifier in the selector,<br />

Receive by specifying a message identifier in the selector,<br />

Committing before all the messages of a transaction group have been<br />

<br />

received.<br />

If in navigating through the queue, the program reaches the end of the queue while<br />

using the NEXT_MESSAGE or NEXT_TRANSACTION option, and you have specified a<br />

blocking receive, then the navigating position is automatically changed to the<br />

beginning of the queue.<br />

By default, a QueueReceiver, Topic Receiver, or TopicSubscriber uses<br />

FIRST_MESSAGE for the first receive call, and NEXT_MESSAGE for the<br />

subsequent receive calls.<br />

Example Scenario<br />

The get_new_orders() procedure retrieves orders from the OE_neworders_<br />

que. Each transaction refers to an order, and each message corresponds to an<br />

individual book in that order. The get_orders() procedure loops through the<br />

messages to retrieve the book orders. It resets the position to the beginning of the<br />

queue using the FIRST_MESSAGE option before the first receive. It then uses the<br />

next message navigation option to retrieve the next book (message) of an order<br />

(transaction). If it gets an exception indicating all message in the current<br />

group/transaction have been fetched, it changes the navigation option to next<br />

transaction and get the first book of the next order. It then changes the navigation<br />

option back to next message for fetching subsequent messages in the same<br />

transaction. This is repeated until all orders (transactions) have been fetched.<br />

Example Code<br />

public void get_new_orders(QueueSession jms_session)<br />

{<br />

Queue queue;<br />

QueueReceiver qrec;<br />

ObjectMessage obj_message;<br />

BolCustomer customer;<br />

BolOrder new_order;<br />

String state;<br />

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