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.

Message Navigation in Receive<br />

}<br />

new_order = (BolOrder)obj_message.getObject();<br />

customer = new_order.getCustomer();<br />

state = customer.getState();<br />

System.out.println("Order: for customer " +<br />

customer.getName());<br />

}<br />

catch (JMSException ex)<br />

{<br />

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

}<br />

return new_order;<br />

JMS Message Consumer Features<br />

When a consumer does the first receive in its session, its gets the first message in the<br />

queue or topic. Subsequent receives get the next message, and so on. The default<br />

behavior works well for FIFO queues and topics, but not for priority ordered<br />

queues. If a high priority message arrives for the consumer, this client program will<br />

not receive the message until it has cleared the messages that were already there for<br />

it.<br />

To provide the consumer a better control in navigating the queue for its messages,<br />

the AQ navigation modes are made available to it as JMS extensions. These modes<br />

can be set at the TopicSubscriber, QueueReceiver or the TopicReceiver.<br />

FIRST_MESSAGE resets the consumer’s position to the beginning of the queue.<br />

<br />

This is a useful mode for priority ordered queues as it allows the consumer to<br />

remove the message on the top of the queue.<br />

NEXT_MESSAGE get the message after the established position of the consumer.<br />

<br />

For example, a NEXT_MESSAGE issued after the position is at the fourth<br />

message, will get the second message in the queue. This is the default behavior.<br />

For transaction grouping<br />

FIRST_MESSAGE resets the consumer’s position to the beginning of the queue<br />

<br />

NEXT_MESSAGE sets the position to the next message in the same transaction.<br />

Creating Applications Using JMS 12-69

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

Saved successfully!

Ooh no, something went wrong!