1 23 24 25 package javax.jms; 26 27 46 47 public class QueueRequestor { 48 49 QueueSession session; Queue queue; TemporaryQueue tempQueue; 52 QueueSender sender; 53 QueueReceiver receiver; 54 55 56 70 71 public 72 QueueRequestor(QueueSession session, Queue queue) throws JMSException { 73 this.session = session; 74 this.queue = queue; 75 tempQueue = session.createTemporaryQueue(); 76 sender = session.createSender(queue); 77 receiver = session.createReceiver(tempQueue); 78 } 79 80 81 92 93 public Message 94 request(Message message) throws JMSException { 95 message.setJMSReplyTo(tempQueue); 96 sender.send(message); 97 return (receiver.receive()); 98 } 99 100 101 116 117 public void 118 close() throws JMSException { 119 120 session.close(); 122 tempQueue.delete(); 123 } 124 } 125 | Popular Tags |