锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲一区国产,2021国产精品视频,国产v综合v亚洲欧美久久http://www.aygfsteel.com/SunRiver/category/15316.htmlTopics about J2EE XML AJAX SOA DB etc.zh-cnWed, 28 Feb 2007 03:11:12 GMTWed, 28 Feb 2007 03:11:12 GMT60The basic steps to write a JMS programhttp://www.aygfsteel.com/SunRiver/archive/2006/10/30/77948.htmlSun RiverSun RiverSun, 29 Oct 2006 17:11:00 GMThttp://www.aygfsteel.com/SunRiver/archive/2006/10/30/77948.htmlhttp://www.aygfsteel.com/SunRiver/comments/77948.htmlhttp://www.aygfsteel.com/SunRiver/archive/2006/10/30/77948.html#Feedback0http://www.aygfsteel.com/SunRiver/comments/commentRss/77948.htmlhttp://www.aygfsteel.com/SunRiver/services/trackbacks/77948.html

1). Steps for Building a JMS Sender Application

1.Get ConnectionFactory and Destination object (Topic or Queue) through JNDI聽聽聽聽聽聽聽聽聽

// Get JNDI InitialContext object

Context jndiContext = new InitialContext();

// Locate ConnectionFactory object via JNDI

TopicConnectionFactory factory =
聽聽聽聽聽 (TopicConnectionFactory) jndiContext.lookup("MyTopicConnectionFactory");

// Locate Destination object (Topic or Queue) through JNDI

Topic weatherTopic = (Topic) jndiContext.lookup("WeatherData");

2.Create a Connection聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
// Create a Connection object from ConnectionFactory object
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽TopicConnection topicConnection = factory.createTopicConnection();

3.Create a Session to send/receive messages

聽聽聽聽聽聽聽聽聽// Create a Session from Connection object.

聽聽聽聽聽聽聽聽聽聽聽聽// 1st parameter controls transaction

聽聽聽聽聽聽聽聽聽聽聽聽// 2nd parameter specifies acknowledgment type

聽聽聽聽聽聽聽聽聽TopicSession session =

聽聽聽聽聽聽聽聽聽聽聽聽topicConnection.createTopicSession (false, Session.CLIENT_ACKNOWLEDGE);

4.Create a MessageProducer (TopicPublisher or QueueSender)

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽// Create MessageProducer from Session object
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽// TopicPublisher for Pub/Sub
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽// QueueSender for Point-to-Point
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽TopicPublisher publisher =session.createPublisher(weatherTopic);

5.Start Connection
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽// Until Connection gets started, message flow
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽// is inhibited: Connection must be started before
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽// messages will be transmitted.
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽topicConnection.start();

6.Send (publish) messages
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽// Create a Message
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽TextMessage message =session.createMessage();
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽message.setText("text:35 degrees");
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽// Publish the message
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽publisher.publish(message);

7.Close Session and Connection

2). Steps for Building a JMS Receiver Application (non-blocking mode)

1.Get ConnectionFactory and Destination object

(Topic or Queue) through JNDI

2.Create a Connection

3.Create a Session to send/receive messages

4.Create a MessageConsumer (TopicSubscriber or QueueReceiver)

聽聽聽聽聽聽聽聽聽聽聽聽// Create Subscriber from Session object
聽聽聽聽聽聽聽聽聽聽聽聽TopicSubscriber subscriber =session.createSubscriber(weatherTopic);

5.
Register MessageListener for non-blocking mode
聽聽聽聽聽聽聽聽聽WeatherListener myListener= new WeatherListener();
聽聽聽聽聽聽聽聽聽// Register MessageListener with TopicSubscriber object
聽聽聽聽聽聽聽聽聽subscriber.setMessageListener(myListener);

6.Start Connection

7.Close Session and Connection

3). Steps for Building a JMS Receiver Application for blocking mode)

1
.Get ConnectionFactory and Destination object (Topic or Queue) through JNDI

2.Create a Connection

3.Create a Session to send/receive messages

4.

Create a MessageConsumer

5.Start Connection

6.

Receive message

7.Close Session and Connection



Sun River 2006-10-30 01:11 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 中山市| 库伦旗| 明光市| 宁波市| 岐山县| 临夏市| 东乌珠穆沁旗| 乐安县| 化州市| 盈江县| 平南县| 光泽县| 荣成市| 行唐县| 宣威市| 大庆市| 萨嘎县| 四子王旗| 惠来县| 东城区| 文成县| 尼木县| 镇沅| 石狮市| 黔西县| 上栗县| 麻江县| 大城县| 新民市| 明水县| 济南市| 梓潼县| 垫江县| 泸州市| 墨竹工卡县| 苗栗县| 县级市| 河源市| 辉县市| 凌源市| 湄潭县|