node-amqp10
node-amqp10 copied to clipboard
Connect does nothing
Hi there,
I am using Amazon MQ using the AMQP connection string and for some or other reason, the promises are not returning anything. No error or success..
I have copied the code from your examples, as well as played around with the policy and for some reason the application just waits..
Please assist. I just decommissioned my RabbitMQ server and now i need to sort the application via amazon MQ.
Code below:
var AMQPClient = require('amqp10').Client,
Promise = require('bluebird'),
Policy = require('amqp10').Policy;
var uri = 'my amazon amqp connection',
msgId = Math.floor(Math.random() * 10000),
client = new AMQPClient();
var client = new AMQPClient(Policy.merge({
senderLinkPolicy: {
callbackPolicy: Policy.Utils.SenderCallbackPolicies.OnSent
}
}, Policy.DefaultPolicy));
client.connect(uri)
.then(function() {
return Promise.all([
client.createReceiver('amq.topic'),
client.createSender('amq.topic')
]);
})
.spread(function(receiver, sender) {
receiver.on('errorReceived', function(err) { /* Check for errors */ });
receiver.on('message', function(message) {
console.log('Rx message: ', message.body);
});
return sender.send({ key: "Value" });
})
.error(function(err) {
console.log("error: ", err);
});
I had this same issue. 1) if the connector is anonymous, you need to specify the SASL mechanism: https://stackoverflow.com/a/43913433/2084315
- if this is an authenticated user, I had to build the url with the creds in the url. (If there's a different way to do this, let me know.)
amqps://user:pw@url:5671
Be sure to run encodeURIComponent()
your password before putting it in the url!
Also, if you have an AmazonMQ broker with failover, only one instance is available at a time. I've witnessed this switching back and forth unreliably as to which one is available. Try switching between your two urls (if you have them) if connect becomes unresponsive. I'm currently investigating whether this library supports setting up a failover.
For those with the same issue under WildFly's embedded ActiveMQ message broker, see: https://issues.jboss.org/browse/WFLY-7823?focusedCommentId=13599179&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-13599179