|
|
@@ -97,20 +97,20 @@ public class IotSubscribe { |
|
|
|
Destination queue = (Destination)context.lookup("QUEUE"); |
|
|
|
|
|
|
|
// 创建连接。 |
|
|
|
log.debug("Befor cf.createConnection"); |
|
|
|
log.warn("Befor cf.createConnection"); |
|
|
|
Connection connection = cf.createConnection(userInfo, password); |
|
|
|
log.debug("Befor connection.addConnectionListener"); |
|
|
|
log.warn("Befor connection.addConnectionListener"); |
|
|
|
((JmsConnection) connection).addConnectionListener(myJmsConnectionListener); |
|
|
|
// 创建会话。 |
|
|
|
// Session.CLIENT_ACKNOWLEDGE: 收到消息后,需要手动调用message.acknowledge()。 |
|
|
|
// Session.AUTO_ACKNOWLEDGE: SDK自动ACK(推荐)。 |
|
|
|
log.debug("Befor connection.createSession"); |
|
|
|
log.warn("Befor connection.createSession"); |
|
|
|
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); |
|
|
|
log.debug("Befor connection.start"); |
|
|
|
log.warn("Befor connection.start"); |
|
|
|
connection.start(); |
|
|
|
|
|
|
|
// 创建Receiver连接。消费消息 |
|
|
|
log.debug("Befor session.createConsumer"); |
|
|
|
log.warn("Befor session.createConsumer"); |
|
|
|
MessageConsumer consumer = session.createConsumer(queue); |
|
|
|
|
|
|
|
// 设置消息侦听 |
|
|
|