浏览 3061 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-05-16
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-05-17
package com.javaeye.jms.jboss;
import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.QueueSender; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class JbossNativeJmsImpl { /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp sender will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 apito get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> start the Producer[jms1.1 spec] by a session * 6> get messege Object or initial it yourself by implements the messegeor * it's sub interfaces * 7> call sender or send it selfing * 8> finallized the connection object or it will throw a warning to you! * * @param messege * @throws NamingException * @throws JMSException */ public void sendingProcessing(String messege) throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageProducer msgp = session.createProducer(dest); QueueSender sender = (QueueSender) msgp; TextMessage msg = session.createTextMessage(); msg.setText(messege); sender.send(msg); conn.close(); } /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp retriver will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 api to get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> retrive a consumer from session * 6> start the jms connection to retrivte the message * 7> get message from consumer * * @return textMessege * @throws NamingException * @throws JMSException */ public String retriveingProcessing() throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageConsumer msgconsumer = session.createConsumer(dest); //MessageListener ml = new JmsListenner(); //msgconsumer.setMessageListener(ml); conn.start(); TextMessage msg = (TextMessage) msgconsumer.receive(); conn.close(); System.out.println("messege is" + msg.getText()); return msg.getText(); } } package com.javaeye.jms.jboss; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.QueueSender; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class JbossNativeJmsImpl { /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp sender will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 apito get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> start the Producer[jms1.1 spec] by a session * 6> get messege Object or initial it yourself by implements the messegeor * it's sub interfaces * 7> call sender or send it selfing * 8> finallized the connection object or it will throw a warning to you! * * @param messege * @throws NamingException * @throws JMSException */ public void sendingProcessing(String messege) throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageProducer msgp = session.createProducer(dest); QueueSender sender = (QueueSender) msgp; TextMessage msg = session.createTextMessage(); msg.setText(messege); sender.send(msg); conn.close(); } /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp retriver will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 api to get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> retrive a consumer from session * 6> start the jms connection to retrivte the message * 7> get message from consumer * * @return textMessege * @throws NamingException * @throws JMSException */ public String retriveingProcessing() throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageConsumer msgconsumer = session.createConsumer(dest); //MessageListener ml = new JmsListenner(); //msgconsumer.setMessageListener(ml); conn.start(); TextMessage msg = (TextMessage) msgconsumer.receive(); conn.close(); System.out.println("messege is" + msg.getText()); return msg.getText(); } } package com.javaeye.jms.jboss; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.QueueSender; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class JbossNativeJmsImpl { /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp sender will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 apito get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> start the Producer[jms1.1 spec] by a session * 6> get messege Object or initial it yourself by implements the messegeor * it's sub interfaces * 7> call sender or send it selfing * 8> finallized the connection object or it will throw a warning to you! * * @param messege * @throws NamingException * @throws JMSException */ public void sendingProcessing(String messege) throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageProducer msgp = session.createProducer(dest); QueueSender sender = (QueueSender) msgp; TextMessage msg = session.createTextMessage(); msg.setText(messege); sender.send(msg); conn.close(); } /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp retriver will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 api to get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> retrive a consumer from session * 6> start the jms connection to retrivte the message * 7> get message from consumer * * @return textMessege * @throws NamingException * @throws JMSException */ public String retriveingProcessing() throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageConsumer msgconsumer = session.createConsumer(dest); //MessageListener ml = new JmsListenner(); //msgconsumer.setMessageListener(ml); conn.start(); TextMessage msg = (TextMessage) msgconsumer.receive(); conn.close(); System.out.println("messege is" + msg.getText()); return msg.getText(); } } package com.javaeye.jms.jboss; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.QueueSender; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class JbossNativeJmsImpl { /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp sender will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 apito get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> start the Producer[jms1.1 spec] by a session * 6> get messege Object or initial it yourself by implements the messegeor * it's sub interfaces * 7> call sender or send it selfing * 8> finallized the connection object or it will throw a warning to you! * * @param messege * @throws NamingException * @throws JMSException */ public void sendingProcessing(String messege) throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageProducer msgp = session.createProducer(dest); QueueSender sender = (QueueSender) msgp; TextMessage msg = session.createTextMessage(); msg.setText(messege); sender.send(msg); conn.close(); } /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp retriver will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 api to get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> retrive a consumer from session * 6> start the jms connection to retrivte the message * 7> get message from consumer * * @return textMessege * @throws NamingException * @throws JMSException */ public String retriveingProcessing() throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageConsumer msgconsumer = session.createConsumer(dest); //MessageListener ml = new JmsListenner(); //msgconsumer.setMessageListener(ml); conn.start(); TextMessage msg = (TextMessage) msgconsumer.receive(); conn.close(); System.out.println("messege is" + msg.getText()); return msg.getText(); } } package com.javaeye.jms.jboss; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.QueueSender; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class JbossNativeJmsImpl { /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp sender will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 apito get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> start the Producer[jms1.1 spec] by a session * 6> get messege Object or initial it yourself by implements the messegeor * it's sub interfaces * 7> call sender or send it selfing * 8> finallized the connection object or it will throw a warning to you! * * @param messege * @throws NamingException * @throws JMSException */ public void sendingProcessing(String messege) throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageProducer msgp = session.createProducer(dest); QueueSender sender = (QueueSender) msgp; TextMessage msg = session.createTextMessage(); msg.setText(messege); sender.send(msg); conn.close(); } /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp retriver will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 api to get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> retrive a consumer from session * 6> start the jms connection to retrivte the message * 7> get message from consumer * * @return textMessege * @throws NamingException * @throws JMSException */ public String retriveingProcessing() throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageConsumer msgconsumer = session.createConsumer(dest); //MessageListener ml = new JmsListenner(); //msgconsumer.setMessageListener(ml); conn.start(); TextMessage msg = (TextMessage) msgconsumer.receive(); conn.close(); System.out.println("messege is" + msg.getText()); return msg.getText(); } } package com.javaeye.jms.jboss; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.QueueSender; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class JbossNativeJmsImpl { /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp sender will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 apito get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> start the Producer[jms1.1 spec] by a session * 6> get messege Object or initial it yourself by implements the messegeor * it's sub interfaces * 7> call sender or send it selfing * 8> finallized the connection object or it will throw a warning to you! * * @param messege * @throws NamingException * @throws JMSException */ public void sendingProcessing(String messege) throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageProducer msgp = session.createProducer(dest); QueueSender sender = (QueueSender) msgp; TextMessage msg = session.createTextMessage(); msg.setText(messege); sender.send(msg); conn.close(); } /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp retriver will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 api to get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> retrive a consumer from session * 6> start the jms connection to retrivte the message * 7> get message from consumer * * @return textMessege * @throws NamingException * @throws JMSException */ public String retriveingProcessing() throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageConsumer msgconsumer = session.createConsumer(dest); //MessageListener ml = new JmsListenner(); //msgconsumer.setMessageListener(ml); conn.start(); TextMessage msg = (TextMessage) msgconsumer.receive(); conn.close(); System.out.println("messege is" + msg.getText()); return msg.getText(); } } package com.javaeye.jms.jboss; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.QueueSender; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class JbossNativeJmsImpl { /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp sender will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 apito get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> start the Producer[jms1.1 spec] by a session * 6> get messege Object or initial it yourself by implements the messegeor * it's sub interfaces * 7> call sender or send it selfing * 8> finallized the connection object or it will throw a warning to you! * * @param messege * @throws NamingException * @throws JMSException */ public void sendingProcessing(String messege) throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageProducer msgp = session.createProducer(dest); QueueSender sender = (QueueSender) msgp; TextMessage msg = session.createTextMessage(); msg.setText(messege); sender.send(msg); conn.close(); } /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp retriver will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 api to get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> retrive a consumer from session * 6> start the jms connection to retrivte the message * 7> get message from consumer * * @return textMessege * @throws NamingException * @throws JMSException */ public String retriveingProcessing() throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageConsumer msgconsumer = session.createConsumer(dest); //MessageListener ml = new JmsListenner(); //msgconsumer.setMessageListener(ml); conn.start(); TextMessage msg = (TextMessage) msgconsumer.receive(); conn.close(); System.out.println("messege is" + msg.getText()); return msg.getText(); } } package com.javaeye.jms.jboss; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.QueueSender; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class JbossNativeJmsImpl { /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp sender will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 apito get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> start the Producer[jms1.1 spec] by a session * 6> get messege Object or initial it yourself by implements the messegeor * it's sub interfaces * 7> call sender or send it selfing * 8> finallized the connection object or it will throw a warning to you! * * @param messege * @throws NamingException * @throws JMSException */ public void sendingProcessing(String messege) throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageProducer msgp = session.createProducer(dest); QueueSender sender = (QueueSender) msgp; TextMessage msg = session.createTextMessage(); msg.setText(messege); sender.send(msg); conn.close(); } /** * @author zuly * * following jms ptp domain, use an simple text message to test * * A jms ptp retriver will following the steps below! * 1> get an ConnectionFactory use JNDI Lookup Or Initial it yourself * 2> use this ConnectionFactory to start a jms connection * [spec to jms 1.1 api to get the main idea of it ] * 3> use connection to create a jms session * 4> get a queue destination / messege agent * 5> retrive a consumer from session * 6> start the jms connection to retrivte the message * 7> get message from consumer * * @return textMessege * @throws NamingException * @throws JMSException */ public String retriveingProcessing() throws NamingException, JMSException{ Context ctx = new InitialContext(); ConnectionFactory cf = (ConnectionFactory) ctx.lookup("java:JmsXA"); Connection conn = cf.createConnection(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = (Queue) ctx.lookup("queue/A"); MessageConsumer msgconsumer = session.createConsumer(dest); //MessageListener ml = new JmsListenner(); //msgconsumer.setMessageListener(ml); conn.start(); TextMessage msg = (TextMessage) msgconsumer.receive(); conn.close(); System.out.println("messege is" + msg.getText()); return msg.getText(); } } |
|
返回顶楼 | |