MDB sending a message
hasc Apr 9, 2007 10:43 AMhi i have a maybe newbie question.
i was trying to make a synchronous jms call. the class MessageProducer sends a request and to a MDB wich in return sends a message back to a temporary queue.
everything seems to work untill the message should be recievedform the temporary queue.
@Name("helloworld") public class MessageProducer { QueueConnection qConnection = null; QueueSession qSession = null; QueueSender qSender = null; QueueRequestor qRequestor = null; @Logger Log log; public void test(){ try{ InitialContext iniCtx = new InitialContext(); Object tmp = iniCtx.lookup("ConnectionFactory"); QueueConnectionFactory qcFactory = (QueueConnectionFactory) tmp; qConnection = qcFactory.createQueueConnection(); Queue queue = (Queue) iniCtx.lookup("queue/quickstart_helloworld_Request"); qConnection = qcFactory.createQueueConnection(); qSession = qConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); qSender = qSession.createSender(queue); String msg = "Hello Queue!"; Message message = qSession.createTextMessage(msg); log.info("Request message"); TemporaryQueue tempQueue = qSession.createTemporaryQueue(); message.setJMSReplyTo(tempQueue); qSender.send(message); QueueReceiver receiver = qSession.createReceiver(tempQueue); log.info("Receiver listens on: #0",receiver.getQueue().getQueueName()); Message answer = receiver.receive(); log.info("message recieved:"); //qRequestor = new QueueRequestor(qSession,queue); //TextMessage answer = (TextMessage) qRequestor.request(message); //log.info("answer::#0",answer.getText()); } catch (Exception e) { ... } } }
and the mdb:
... try { TextMessage response = qSession.createTextMessage("Hello TempQueue!"); System.out.println("try to get JMPReplyTo"); Queue replyQueue = (Queue) recvMsg.getJMSReplyTo(); System.out.println("replyQueue:" + replyQueue.getQueueName()); QueueSender replySender = qSession.createSender(replyQueue); System.out.println("send response"); replySender.send(replyQueue,response); replySender.close(); } catch(Exception e){ e.printStackTrace(); }[ ...
after executing test() nothing happens, the console JBoss AS console says:
16:31:05,328 INFO [MessageProducer] Request message 16:31:05,328 INFO [MessageProducer] Receiver listens on: JMS_TQ8 16:31:05,375 INFO [STDOUT] Received Message: Hello Queue! 16:31:05,375 INFO [STDOUT] try to get JMPReplyTo 16:31:05,375 INFO [STDOUT] replyQueue:JMS_TQ8 16:31:05,375 INFO [STDOUT] send response
and in the log file i get a few SocketManager exceptions which are not displayed in the console
is it possible what i am trying to do? can someone tell me why this doesnt work? help would be appreciated.
thanks,
hasc