锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产一区二区女,日韩123区,欧美日韩中文字幕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 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 西乡县| 上饶县| 宜宾市| 靖州| 扶绥县| 翁牛特旗| 巴林左旗| 武汉市| 来宾市| 元氏县| 竹山县| 特克斯县| 武夷山市| 合川市| 邛崃市| 峨眉山市| 富顺县| 云林县| 乌什县| 张家川| 博客| 纳雍县| 荥阳市| 日照市| 隆回县| 张家港市| 湾仔区| 阳春市| 古丈县| 无为县| 高雄市| 博兴县| 云霄县| 灵川县| 安图县| 新建县| 西充县| 永德县| 永年县| 张家口市| 商河县|