I met a problem when using exchange.publish
to push message.
my code fragment as follow
exc.pushblish('', JSON.stringify(message), {}, function(){
console.log("message published");
});
Every time push the message, would output the log, sadly it can't work as my expect.
After read the doc exchange.publish(routingKey, message, options, callback), I found some description:
callback
is a function that will get called if the exchange is in confirm mode, the value sent will be true or false, this is the presense of a error so true, means an error occured and false, means the publish was successfull
my exchange object new as:
var exc = connection.exchange("ethereum.exchange", options = { type: 'fanout', durable: true, autoDelete: false }, function(exchange){
console.log("exchange" + exchange.name + "is opened");
});
horriblely! without confirm mode when create exchange, when publish message, it would the callback function would not be called.
So, to solve the problem, we should add confirm: true
for connection.exchange function second args options.
网友评论