Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errorReceived events don't work #344

Open
swilliams-a3digital opened this issue Dec 26, 2017 · 2 comments
Open

errorReceived events don't work #344

swilliams-a3digital opened this issue Dec 26, 2017 · 2 comments

Comments

@swilliams-a3digital
Copy link

I found these examples from your samples:

sender.on('errorReceived', function (tx_err) { console.warn('===> TX ERROR: ', tx_err); });
receiver.on('errorReceived', function (rx_err) { console.warn('===> RX ERROR: ', rx_err); });

But they don't work. If I bring down my activemq server I don't get any errorReceived events.

@swilliams-a3digital
Copy link
Author

It looks like your sample documentation is out of date. I read through the code and this worked:
const AMQPClient = require("amqp10").Client;
const activeMQPolicy = require("amqp10").Policy;
const client = new AMQPClient(activeMQPolicy.ActiveMQ);
client.on(AMQPClient.ErrorReceived, (err) => {
console.log(err received ${err});
});

@swilliams-a3digital
Copy link
Author

Here is what I ended up doing for error handling. Basically I wanted to keep the connection going and re-establish my receiver on disconnect. This was able to survive bringing my active MQ server down and up. Nothing else I tried could survive that and keep working. If there is a better way, please advise.

const AMQPClient = require("amqp10").Client;
const Promise = require("bluebird");
const activeMQPolicy = require("amqp10").Policy;
// not sure if this is necessary or wise
activeMQPolicy.Default.reconnect.retries = 10000;
activeMQPolicy.ActiveMQ.reconnect.retries = 10000;
const client = new AMQPClient(activeMQPolicy.ActiveMQ);
subscriber = null;
client.on('connected', () => {
console.log(connected to AMQP Broker);
client.createReceiver("logging.test").then(r => {
subscriber = r;
r.on("message", message => console.log(Rx message: ${message.body}));
});
});
client.on(AMQPClient.ConnectionClosed, () => {
console.log(amqp connection closed);
subscriber = null;
});
client.on(AMQPClient.ErrorReceived, (err) => {
console.log(err received ${err});
});
let url = "amqp://user:notmypasword@localhost:5672";
client.connect(url)
.then(c => {
console.log('connection initialized');
return null;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant