public class JMSClient
{
public static String MESSAGE_1 = "c encoding=\"UTF-8\"?> SOAP Message...";
private static final long WAIT_TIME = 5 * 1000L;
public static void main(String[] args) throws Exception
{
ActiveMQConnectionFactory factory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
ActiveMQQueue pubTopic = new ActiveMQQueue("queue/A");
ActiveMQQueue subTopic = new ActiveMQQueue("queue/B");
Connection connection = factory.createConnection();
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(pubTopic);
MessageConsumer consumer = session.createConsumer(subTopic);
connection.start();
producer.send(session.createTextMessage(MESSAGE_1));
TextMessage textMessage = (TextMessage)
consumer.receive(1000 * 10);
if(textMessage == null)
{
System.out.println("Response timed out.");
}
else
{
System.out.println("Response was: " +
textMessage.getText());
}
System.out.println("Closing.");
connection.close();
}
}
???
Chapter 11
[ 215 ]
The JMSClient is placed in the folder ch11\WebServiceInJmsChannel\
03_BindJms\src.
Pages:
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304