41 |
msg = "Default"; |
msg = "Default"; |
42 |
|
|
43 |
try { |
try { |
|
|
|
|
|
|
44 |
QueueConnection connection = connectionFactory.createQueueConnection(); |
QueueConnection connection = connectionFactory.createQueueConnection(); |
45 |
|
|
46 |
|
|
51 |
|
|
52 |
message.setText(msg); |
message.setText(msg); |
53 |
message.setJMSReplyTo(responseQueue); |
message.setJMSReplyTo(responseQueue); |
54 |
|
|
|
|
|
55 |
producer.send(message); |
producer.send(message); |
|
producer.close(); |
|
|
connection.close(); |
|
|
///new session for receiving |
|
56 |
|
|
57 |
|
|
|
connection = connectionFactory.createQueueConnection(); |
|
|
session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); |
|
58 |
QueueReceiver consumer = session.createReceiver(responseQueue); |
QueueReceiver consumer = session.createReceiver(responseQueue); |
59 |
|
connection.start(); //incomming messages is not received until a start is given |
60 |
|
|
61 |
|
|
62 |
|
TextMessage reply = (TextMessage) consumer.receive(500); //wait max 500 ms for replay |
|
Message reply = consumer.receive(1000); //wait max 500 ms for replay |
|
63 |
|
|
64 |
|
|
65 |
if (reply != null) |
if (reply != null) |
66 |
response.getWriter().print("Reply: " /*+ reply.getText()*/ ); |
response.getWriter().print("Reply: " + reply.getText() ); |
67 |
else |
else |
68 |
response.getWriter().print("No reply !!!"); |
response.getWriter().print("No reply !!!"); |
69 |
|
|