【发布时间】:2019-07-17 21:33:17
【问题描述】:
我正在开发一个使用来自 ActiveMQ 队列的消息的套接字 IO 应用程序。我正在为 Node JS 使用 stomp 库
在大多数情况下,它工作正常,但我需要能够重新发送未确认的消息。跳过 amq.ack(message) 的消息不会被重试并显示为等待 ActiveMQ Web 控制台。有什么方法可以让我重新发送它们吗?
const subscribeHeaders = {
destination,
ack: 'client-individual'
};
amq.subscribe(subscribeHeaders, (error, message) => {
if (error) {
logger.error(`subscribe error ${error.message}`);
return;
}
message.readString('utf-8', (err, body) => {
if (err) {
logger.error(`read message error ${err.message}`);
return;
}
const notificationData = JSON.parse(body);
const { deviceId } = notificationData;
if (io.sockets.adapter.rooms[deviceId]) {
io.to(deviceId).emit('notification', notificationData);
amq.ack(message);
}
});
});
【问题讨论】:
标签: node.js socket.io activemq