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.

Publishing a Message Using a Topic Publisher—with Minimal Specification<br />

'MYSID', myport, 'oci8');<br />

t_conn = tc_fact.createTopicConnection("jmstopic", "jmstopic");<br />

jms_sess = t_conn.createTopicSession(true, Session.CLIENT_ACKNOWLEDGE);<br />

/* create topic publisher */<br />

publisher1 = jms_sess.createPublisher(null);<br />

/* get topic object */<br />

shipped_orders = ((AQjmsSession )jms_sess).getTopic('WS', 'Shipped_Orders_<br />

Topic');<br />

/* create text message */<br />

TextMessage jms_sess.createTextMessage();<br />

/* publish specifying the topic */<br />

publisher1.publish(shipped_orders, text_message);<br />

Example 2 - publish without specifying topic<br />

TopicConnectionFactory tc_fact = null;<br />

TopicConnection t_conn = null;<br />

TopicSession jms_sess;<br />

TopicPublisher publisher1;<br />

Topic shipped_orders;<br />

int myport = 5521;<br />

/* create connection and session */<br />

tc_fact = AQjmsFactory.getTopicConnectionFactory("MYHOSTNAME",<br />

"MYSID", myport, "oci8");<br />

t_conn = tc_fact.createTopicConnection("jmstopic", "jmstopic");<br />

/* create topic session */<br />

jms_sess = t_conn.createTopicSession(true, Session.CLIENT_ACKNOWLEDGE);<br />

/* get shipped orders topic */<br />

shipped_orders = ((AQjmsSession )jms_sess).getTopic("OE", "Shipped_Orders_<br />

Topic");<br />

publisher1 = jms_sess.createPublisher(shipped_orders);<br />

/* create text message */<br />

TextMessage jms_sess.createTextMessage();<br />

/* publish without specifying the topic */<br />

publisher1.publish(text_message);<br />

15-14 <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!