Skip to content

Commit b842123

Browse files
committed
optimize rabbitmq
1 parent ad13b1e commit b842123

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

config/rabbitmq.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* amqp 参数配置
3+
* @see https://github.com/dial-once/node-bunnymq
4+
*/
5+
6+
module.exports = {
7+
host: 'amqp://localhost', // connect url
8+
prefetch: 5, // number of fetched messages at once on the channel
9+
requeue: true, // requeue put back message into the broker if consumer crashes/trigger exception
10+
timeout: 1000, // time between two reconnect (ms)
11+
rpcTimeout: 1000 // default timeout for RPC calls. If set to '0' there will be none.
12+
}

server/utils/rabbitmq.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
/**
22
* 消息队列,简单实现了消息订阅、发布和RPC调用
3+
* @see https://github.com/dial-once/node-bunnymq
34
* 也可参考 https://github.com/tjmehta/amqplib-rpc 实现方式
45
*/
56

67
var bunnymq = require('bunnymq')
7-
8-
var config = {
9-
host: 'amqp://localhost', // connect url
10-
prefetch: 5, // number of fetched messages at once on the channel
11-
requeue: true, // requeue put back message into the broker if consumer crashes/trigger exception
12-
timeout: 1000, // time between two reconnect (ms)
13-
rpcTimeout: 1000 // default timeout for RPC calls. If set to '0' there will be none.
14-
}
8+
var config = require('../../config/rabbitmq')
159

1610
var conn = bunnymq(config)
1711
var producer = conn.producer

0 commit comments

Comments
 (0)