tjmehta / coworkers

A RabbitMQ Microservice Framework in Node.js
MIT License
610 stars 36 forks source link

Opening exclusive queue per request and leaving them open #48

Closed combsco closed 8 years ago

combsco commented 8 years ago

I've had this problem with the amqplib-rpc library. I was trying to use amqplib-rpc on my API Gateway and it would just keep creating new exclusive channels. I had to switch to node-bunnymq because it creates one exclusive queue for responses.

So if I run this code 4 times... I get 4 exclusive queues that don't delete themselves until Coworkers process is killed. This is following the RPC example from the readme...

Imgur

Client

app.use(function * (next) {
  if (this.queueName === 'user.create') {
    const replyMsg = yield this.request('tenant.read', {tenant_id: this.message.content.tenant_id})
    // do something with replyMsg
  }
  yield next
})

Server

app.queue('tenant.read', function * () {
  // return the good stuff...
  this.reply(new Buffer(JSON.stringify(result))
  this.ack = true
})
tjmehta commented 8 years ago

Wow. Definitely a bug. I haven't used coworkers rpc in my apps. So I will definitely fix this ASAP. If you have a moment, please help by adding a broken test. Although, this seems like a bug with amqplib-rpc

Typed using my thumbs..

On Aug 26, 2016, at 9:44 AM, Chris. notifications@github.com wrote:

I've had this problem with the amqplib-rpc library. I was trying to use amqplib-rpc on my API Gateway and it would just keep creating new exclusive channels. I had to switch to node-bunnymq because it creates one exclusive queue for responses.

So if I run this code 4 times... I get 4 exclusive queues that don't delete themselves until Coworkers process is killed. This is following the [RPC example from the readme]...(https://github.com/tjmehta/coworkers#rpc--request-reply-checkreplyqueue-example)

Client

app.use(function * (next) { if (this.queueName === 'user.create') { const replyMsg = yield this.request('tenant.read', {tenant_id: this.message.content.tenant_id}) // do something with replyMsg } yield next }) Server

app.queue('tenant.read', function * () { // return the good stuff... this.reply(new Buffer(JSON.stringify(result)) this.ack = true }) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

tjmehta commented 8 years ago

Have a fix coming very soon: https://github.com/tjmehta/amqplib-rpc/pull/10

tjmehta commented 8 years ago

fixed coworkers@v0.7.2

tjmehta commented 8 years ago

Turns out exclusive queues do not auto-close when their channel is closed.

combsco commented 8 years ago

Awesome thanks for the update!

tjmehta commented 8 years ago

Np, lmk if you hit any other problems or have any questions