rabbitmq客户端订阅通道侦听器给出内存泄漏警告

时间:2018-08-21 08:20:30

标签: node.js rabbitmq

我的代码如下所示:

scheduler.js

const callMethodForeverRabbitMq = () => {


    cron.schedule('*/1 * * * * *', function () {

        console.log('rabbitmq is calling');


        rabbitMqClientPipeline.subscribeWalletChannel((err, data) => {
            console.log('rabbitmq subscribe called');
            if (!err) {
                console.log('message is ' + data);
            }
        })
    });


};

rabbitmq.js

const subscribeWalletChannel = (cb) => {

    console.log('subscribe method called');

    client.subscribe('channel_name', function () {
        client.on('message', function (topic, message, packet) {
            console.log("Received '" + message + "' on '" + topic + "'");
            return cb(null, message);
        });
    });

}

运行此代码后,它会警告我:

0|app      | (node:8973) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit

0 个答案:

没有答案