-
-
Notifications
You must be signed in to change notification settings - Fork 521
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
How to correct disconnect multiple consumers? #66
Comments
Hi @al66, you can call const consumers = [...]
await Promise.all(consumers)
console.log('disconnected') |
Hi @tulios . That was my first try. I think the reason is, that the cluster is also disconnected in the first call. /**
* @return {Promise}
*/
const disconnect = async () => {
try {
if (runner) {
await runner.stop()
logger.debug('consumer has stopped, disconnecting', { groupId })
}
await cluster.disconnect()
} catch (e) {}
logger.info('Stopped', { groupId })
} Here is my original coding: /**
* Service stopped lifecycle event handler
*/
async stopped() {
await Promise.all(this.subscriptions.map(async (subscription) => {
try {
await subscription.consumer.disconnect();
this.logger.info(`Consumer for subscription ${subscription.id} stopped`);
} catch(err) {
this.logger.warn(`Stopping consumer for subscription ${subscription.id} failed`);
}
Promise.resolve();
}));
this.logger.info(`All consumers disconnected`);
} |
You are right, I think we usually subscribe to different topics instead of creating several consumers. I'll create an issue to add the |
You can follow issue #67 |
This wasn't necessary, please check issue #67 (just to document) |
I have some trouble with disconnecting multiple consumers I have started with different groupId's.
Hopefully you can help me.
This is my code for disconnecting...
The text was updated successfully, but these errors were encountered: