--- miscJava/Test3/src/dk/thoerup/messagedriven/ReverserServlet.java 2011/04/07 19:14:32 1275 +++ miscJava/Test3/src/dk/thoerup/messagedriven/ReverserServlet.java 2011/04/07 19:24:51 1276 @@ -41,8 +41,6 @@ msg = "Default"; try { - - QueueConnection connection = connectionFactory.createQueueConnection(); @@ -53,25 +51,19 @@ message.setText(msg); message.setJMSReplyTo(responseQueue); - - + producer.send(message); - producer.close(); - connection.close(); - ///new session for receiving - connection = connectionFactory.createQueueConnection(); - session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); QueueReceiver consumer = session.createReceiver(responseQueue); + connection.start(); //incomming messages is not received until a start is given - - Message reply = consumer.receive(1000); //wait max 500 ms for replay + TextMessage reply = (TextMessage) consumer.receive(500); //wait max 500 ms for replay if (reply != null) - response.getWriter().print("Reply: " /*+ reply.getText()*/ ); + response.getWriter().print("Reply: " + reply.getText() ); else response.getWriter().print("No reply !!!");