Foo-Foo-MQ / foo-foo-mq

Abstractions around RabbitMQ
MIT License
48 stars 24 forks source link

Queues with expiry #33

Open TimBailey-pnk opened 2 years ago

TimBailey-pnk commented 2 years ago

Hi, I have a problem with foofoomq/rabbot caching queues with expiry.

When the queue is defined with an expires, then its deleted n ms after the last message is removed. I'm using these expiring queues in my message retry mechanism. When a message needs to be delayed for retry, then I create my queue (with expiry) bind it to the exchange and publish the message. The problem occurs when the next message that needs to be delayed is processed....if the queue has expired, then its removed by rabbit, but the queue is cached in the this.promises[channelName] (and some others). The code that is called to addQueue then checks this cache and these skips the queue creation as it thinks it must exist already. This is when my code fails.

A quick fix for my issue is, as I know they are expiring, add a new option named force which can override the cache check and regenerate the queue promise etc. PR for that https://github.com/Foo-Foo-MQ/foo-foo-mq/pull/32 Can you see any issues with my brutal promise overwriting change?

There was a similar issue ages ago to do with rabbot deleted queues failing to be recreated due to similar caching issues (https://github.com/arobson/rabbot/issues/97)

FYI The retry mechanism I'm using is "inspired" by option 3 in this article https://engineering.nanit.com/rabbitmq-retries-the-full-story-ca4cc6c5b493

TimBailey-pnk commented 2 years ago

Actually the proposed fix doesnt work.

zlintz commented 1 year ago

@TimBailey-pnk is this still a thing or can we close this issue?