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.

int new_orders = 1;<br />

try<br />

{<br />

JMS Message Consumer Features<br />

/* get a handle to the new_orders queue */<br />

queue = ((AQjmsSession) jms_session).getQueue("OE","OE_neworders_que");<br />

qrec = jms_session.createReceiver(queue);<br />

/* set navigation to first message */<br />

((AQjmsTopicSubscriber)qrec).setNavigationMode(AQjmsConstants.NAVIGATION_FIRST_<br />

MESSAGE);<br />

while(new_orders != 0)<br />

{<br />

try{<br />

/* wait for a message to show up in the topic */<br />

obj_message = (ObjectMessage)qrec.receiveNoWait();<br />

if (obj_message != null) /* no more orders in the queue */<br />

{<br />

System.out.println(" No more orders ");<br />

new_orders = 0;<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 />

/* Now get the next message */<br />

((AQjmsTopicSubscriber)qrec).setNavigationMode(AQjmsConstants.NAVIGATION_NEXT_<br />

MESSAGE);<br />

}catch(AQjmsException ex)<br />

{ if (ex.getErrorNumber() == 25235)<br />

{<br />

System.out.println("End of transaction group");<br />

((AQjmsTopicSubscriber)qrec).setNavigationMode(AQjmsConstants.NAVIGATION_NEXT_<br />

TRANSACTION);<br />

Creating Applications Using JMS 12-71

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

Saved successfully!

Ooh no, something went wrong!