使用nodejs在使用消息选择器时订阅ActiveMQ Stomp



我想使用nodejs订阅ActiveMQ服务器。我的问题是,现在,我的node-stomp-client(https://github.com/easternbloc/node-stomp-client(当前正在获取所有正在从MQ出版的消息,而我真的很想要要使用"消息选择器",以免我将所有消息传递到Nodejs。有什么方法可以像Java订阅ActiveMQ一样使用NodeJ中的消息选择器?(Java中的消息选择器参考:http://timjansen.github.io/jarfiller/guide/jms/selectors.xhtml(

在订阅ActiveMQ代理时,您可以在订阅呼叫随附的选项值中使用选项名称" Selector"将JMS样式消息选择器包含在选项值中。然后,经纪人将应用选择器并过滤发送给客户端订阅的消息。

请参阅ActiveMQ踩踏文档。

从Stomp Client网站订阅将标题作为参数。

var Stomp = require('stomp-client');
var destination = '/queue/someQueueName';
var client = new Stomp('127.0.0.1', 61613, 'user', 'pass');
client.connect(function(sessionId) {
    client.subscribe(destination, function(body, headers) {
        console.log('This is the body of a message on the subscribed queue:', body);
    });
    client.publish(destination, 'Oh herrow');
});

最新更新