Oracle8i Application Developer's Guide - XML Release 3 (8.1.7) Part Number A86030-01 |
|
Using Oracle Advanced Queuing (AQ) in XML Data Exchange, 5 of 6
XML messages can be enqueued and dequeued from an AQ queue using JMS (Java Messaging Standard). Example 2 shows you how to publish and subscribe an XML message as a JMS TextMessage. Refer to Oracle8i Application Developer's Guide - Advanced Queuing for more examples.
See Oracle8i Application Developer's Guide - Advanced Queuing Chapter 13, "JMS Administrative Interface- Basic Operations" for information on setting up the AQ JMS environment.
The following lists the tasks performed by Example 2 using JMS to publish an XML message:
The following lists the tasks performed by Example 2 using JMS to receive (subscribe) an XML message:
Here is the Java code listing using JMS to process an XML message.
public void publishXMLMessage (String host, String ora_sid, int port, String driver) throws JMS Exception { TopicConnectionFactory tc_fact; TopicConnection t_conn; TopicSession jms_sess; Topic mlmsg_topic; TextMessage xmlmsg; TopicPublisher xmlmsg_publisher; // create a ConnectionFactory tc_fact = AQjmsFactory.createTopicConnectionFactory( host, ora_sid, port, driver); //create a Topic Connection t_conn = tc_fact.createTopicConnection ("scott", "tiger"); //create a JMS Session jms_sess = t_conn.createTopicSession(true, 0); // Get a Topic object xmlmsg_topic = ((AQjmsSession)jms_sess).getTopic("scott", "xmlmsg_topic"); //create Topic publisher xmlmsg_publisher = jms_sess.createPublisher(null); // create XML text message xmlmsg = jms_sess.createTextMessage(); //Publish message xmlmsg_publisher.publish(xmlmsg_topic, xmlmsg); jms_sess.commit(); } public void receiveXMLMessage (String host, String ora_sid, int port, String driver) throws JMS Exception { TopicConnectionFactory tc_fact; TopicConnection t_conn; TopicSession jms_sess; Topic xmlmsg_topic; TextMessage xmlmsg; TopicSubscriber xmlmsg_subscriber; // create a ConnectionFactory tc_fact = AQjmsFactory.createTopicConnectionFactory( host, ora_sid, port, driver); //create a Topic Connection t_conn = tc_fact.createTopicConnection ("scott", "tiger"); //create a JMS Session jms_sess = t_conn.createTopicSession(true, 0); // Get a Topic object xmlmsg_topic = ((AQjmsSession)jms_sess).getTopic("scott", "xmlmsg_topic"); //create Topic subscriber xmlmsg_subscriber = jms_sess.createDurableSubscriber(xmlmsg_topic, "XmlMsg_ Subscriber"); // create XML text message xmlmsg = (TextMessage)xmlmsg_subscriber.receive(); //Process Text Message jms_sess.commit(); }
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|