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.

}<br />

ObjectMessage obj_message;<br />

BolCustomer customer;<br />

BolOrder new_order = null;<br />

String state;<br />

JMS Message Consumer Features<br />

try<br />

{<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 />

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

obj_message = (ObjectMessage)qrec.receive();<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 />

Example: Block for a Maximum of 60 Seconds<br />

public BolOrder get_new_order2(QueueSession jms_session)<br />

{<br />

Queue queue;<br />

QueueReceiver qrec;<br />

ObjectMessage obj_message;<br />

BolCustomer customer;<br />

BolOrder new_order = null;<br />

String state;<br />

try<br />

{<br />

Creating Applications Using JMS 12-67

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

Saved successfully!

Ooh no, something went wrong!