小编fed*_*-sg的帖子

通过 Amqplib 连接到 RabbitMQ 时设置 Heartbeat

通过amqplib连接RabbitMQ时,无法设置Heartbeat参数的值。

我这样做:

// NPM Modules
const amqp = require('amqplib/callback_api');
const withAutoRecovery = require('amqplib-auto-recovery');

// Application configuration
const config = settings.getConfig();

withAutoRecovery(amqp, {
  onError: (err) => { console.log(err.message); },
  isErrorUnrecoverable: (err) => { console.log(err) }
}).connect(config.rabbitmq, (err, connection) => {
    // If there are connection errors
    if (err) {
        console.error(this.conn_str_amqp);
        console.error('[AMQP] Connection error:', err.message); 
    } else if (connection) {
        // Connection Error Event
        connection.on('error', (err) => {
            if (err.message !== 'Connection closing') {
                console.error('[AMQP] Closing …
Run Code Online (Sandbox Code Playgroud)

rabbitmq node.js

5
推荐指数
1
解决办法
5528
查看次数

标签 统计

node.js ×1

rabbitmq ×1