1 22 package org.jboss.ejb3.test.strictpool; 23 24 import javax.jms.QueueSession ; 25 import javax.jms.Queue ; 26 import javax.jms.QueueSender ; 27 import javax.jms.TextMessage ; 28 import javax.jms.QueueReceiver ; 29 import javax.jms.Message ; 30 import javax.jms.ObjectMessage ; 31 32 import EDU.oswego.cs.dl.util.concurrent.CountDown; 33 import org.jboss.logging.Logger; 34 35 40 public class MDBInvoker extends Thread 41 { 42 QueueSession session; 43 Queue queueA; 44 Queue queueB; 45 int id; 46 CountDown done; 47 public Exception runEx; 48 49 public MDBInvoker(QueueSession session, Queue queueA, Queue queueB, int id, CountDown done) 50 { 51 super("MDBInvoker#"+id); 52 this.session = session; 53 this.queueA = queueA; 54 this.queueB = queueB; 55 this.id = id; 56 this.done = done; 57 } 58 public void run() 59 { 60 System.out.println("Begin run, this="+this); 61 try 62 { 63 QueueSender sender = session.createSender(queueA); 64 TextMessage message = session.createTextMessage(); 65 message.setText(this.toString()); 66 sender.send(message); 67 QueueReceiver receiver = session.createReceiver(queueB); 68 Message reply = receiver.receive(20000); 69 if( reply == null ) 70 { 71 runEx = new IllegalStateException ("Message receive timeout"); 72 } 73 else 74 { 75 Message tm = (Message ) reply; 76 System.out.println(tm); 77 } 78 sender.close(); 79 receiver.close(); 80 } 81 catch(Exception e) 82 { 83 runEx = e; 84 } 85 done.release(); 86 System.out.println("End run, this="+this); 87 } 88 89 } 90 | Popular Tags |