1 23 24 package javax.jms; 25 26 45 46 public class TopicRequestor { 47 48 TopicSession session; Topic topic; TemporaryTopic tempTopic; 51 TopicPublisher publisher; 52 TopicSubscriber subscriber; 53 54 55 69 70 public 71 TopicRequestor(TopicSession session, Topic topic) throws JMSException { 72 this.session = session; 73 this.topic = topic; 74 tempTopic = session.createTemporaryTopic(); 75 publisher = session.createPublisher(topic); 76 subscriber = session.createSubscriber(tempTopic); 77 } 78 79 80 91 92 public Message 93 request(Message message) throws JMSException { 94 message.setJMSReplyTo(tempTopic); 95 publisher.publish(message); 96 return(subscriber.receive()); 97 } 98 99 100 115 116 public void 117 close() throws JMSException { 118 119 session.close(); 121 tempTopic.delete(); 122 } 123 } 124 | Popular Tags |