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

amqp-client.conn must not be private for shutdown to work #3

Open
tobias-neubert opened this issue Feb 9, 2015 · 1 comment
Open

Comments

@tobias-neubert
Copy link

I am trying to use the shutdown function to exit gracefully but get the following exception:

TypeError: Cannot read property 'then' of undefined
at QueueWrapper.module.exports.QueueWrapper.unbind (/bas-router/node_modules/amqp-as-promised/lib/queue-wrapper.js:64:22)
at QueueWrapper.unbind (bas-router/node_modules/amqp-as-promised/lib/queue-wrapper.js:4:61)
at /bas-router/node_modules/amqp-as-promised/lib/amqp-client.js:184:18

To me it looks as if the queue-wrapper needs access to the amqp-client conn property. So I added the conn property to the exported object in amqp-client.js. But that results in another exception.

Here is how I am trying to get things done: I am thankful for any help,
Tobias

function start() {
    // Register the exit hooks
    process.on('SIGTERM', exit);
    process.on('SIGINT', exit);

    return establishRegisterProviderQueue().then(function () {
        return establishRouterQueue();
    });
};

function exit() {
    logger.info('Exiting');
    amqpc.shutdown().then(function () {
        logger.info('Closed AMQP connection gracefully.');
        process.exit(0);
    }).catch(function (error) {
        logger.warn('Could not close AMQP connection gracefully. Will exit anyway: %s', error.stack);
        process.exit(10);
    });
}

function establishRegisterProviderQueue() {
    logger.info('Establishing provider registration');
    return Q.all([
        amqpc.exchange(REGISTER_PROVIDER_EXCHANGE_NAME, {
            type: 'fanout',
            passive: false
        }),
        amqpc.queue(REGISTER_PROVIDER_QUEUE_NAME, {passive: false})
    ]).spread(function (exchange, queue) {
        return amqpc.bind(exchange, queue, REGISTER_PROVIDER_ROUTING_KEY, registerProvider);
    });
};
@fred-o
Copy link
Contributor

fred-o commented Mar 30, 2015

Hi! As far as I can tell, the queue-wrapper object already should hold a reference to amqpc.conn, and it doesn't look like it is ever deleted. Does the queue work correctly for you up until shutdown, or could it be some kind of trouble with the initialization?

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

2 participants