【问题标题】:Consuming JMS messages by node.js通过 node.js 消费 JMS 消息
【发布时间】:2011-12-22 09:33:10
【问题描述】:

是否有任何 npm 模块(或只是一个库)供 node.js 使用来自 JMS 端点的消息 (tcp://jms.someadress.com:61616)

【问题讨论】:

    标签: node.js jms


    【解决方案1】:

    如果您使用的是 RabbitMQ(或其他 AMQP 实现者),您可以使用 node-amqp,这是一个使用 AMQP 协议连接到消息传递服务器的模块。

    https://github.com/postwait/node-amqp.git

    【讨论】:

      【解决方案2】:

      使用带有stomp-jsnode-stomp-client 的Stomp 协议。 ActiveMQ supports Stomp 与 JBoss HornetQ 相同。我假设您使用 ActiveMQ,因为端口号与其默认值匹配。

      我猜应该还有 JMS-Stomp 桥,您可以将它们用于商业 JMS 实现。

      【讨论】:

        【解决方案3】:

        注意,squaremo/amqp.node 现在似乎比node-amqp 维护得更多,甚至在RabbitMQ docs 中被推荐。

        npm install amqplib
        
        var q = 'tasks';
        
        var open = require('amqplib').connect('amqp://localhost');
        
        // Publisher
        open.then(function(conn) {
          return conn.createChannel();
        }).then(function(ch) {
          return ch.assertQueue(q).then(function(ok) {
            return ch.sendToQueue(q, Buffer.from('something to do'));
          });
        }).catch(console.warn);
        
        // Consumer
        open.then(function(conn) {
          return conn.createChannel();
        }).then(function(ch) {
          return ch.assertQueue(q).then(function(ok) {
            return ch.consume(q, function(msg) {
              if (msg !== null) {
                console.log(msg.content.toString());
                ch.ack(msg);
              }
            });
          });
        }).catch(console.warn);
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-02-02
          • 2020-03-18
          • 2016-06-14
          • 1970-01-01
          • 1970-01-01
          • 2015-09-19
          • 2013-08-08
          • 2012-02-01
          相关资源
          最近更新 更多