短信消息处理
tcp://localhost:61616
public class SmsQueueConsumer implements MessageListener { @Override public void onMessage(Message message) { String topicName = null; try { Queue jmsReplyTo = (Queue) message.getJMSDestination(); ; topicName = jmsReplyTo.getQueueName(); } catch (JMSException e) { e.printStackTrace(); } if (message instanceof TextMessage) { try { System.out.println(Thread.currentThread().getName() + ",收到队列(" + topicName + ")的消息:" + ((TextMessage) message).getText()); } catch (JMSException ex) { throw new RuntimeException(ex); } } else { throw new IllegalArgumentException("Message must be of type TextMessage"); } }}
tips:
本文由导入,原文链接: