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 Publish-Subscribe Model Features<br />

}<br />

Topic Publisher<br />

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

}<br />

Messages are published using TopicPublisher:<br />

A TopicPublisher is created by passing a Topic to a session’s<br />

createPublisher method. A client also has the option of creating a<br />

TopicPublisher without supplying a Topic. In this case, a Topic must be<br />

specified on every publish operation. A client can specify a default delivery mode,<br />

priority and time-to-live for all messages sent by the TopicPublisher. It can also<br />

specify these options on a per message basis.<br />

Example Scenario and Code<br />

In the BooksOnline application, booked orders are published to the OE.OE_<br />

bookedorders_topic<br />

public void book_new_order(TopicSession jms_session, ObjectMessage obj_message)<br />

{<br />

TopicPublisher publisher;<br />

Topic topic;<br />

}<br />

try<br />

{<br />

/* get a handle to the booked_orders topic */<br />

topic = ((AQjmsSession) jms_session).getTopic("OE",<br />

"OE_bookedorders_topic");<br />

publisher = jms_session.createPublisher(topic);<br />

publisher.publish(topic, obj_message);<br />

jms_session.commit();<br />

}<br />

catch (JMSException ex)<br />

{<br />

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

}<br />

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