node-amqp-connection-manager icon indicating copy to clipboard operation
node-amqp-connection-manager copied to clipboard

option to disable inner _messages queue

Open gwh-cpnet opened this issue 7 years ago • 6 comments

I am well aware of that this repo is about maintaining the data flows.

However in the edge environment, where the broker may not be accessible and robust as cloud environment, accumulating data at client side would consume all the memory and cause the system to break.

I wish there is some strategies can be added to limit the memory usage.

gwh-cpnet avatar Nov 27 '18 01:11 gwh-cpnet

That's an interesting idea. You could do this by supplying some function that evicts old messages from _messages when it gets too full?

jwalton avatar Nov 27 '18 15:11 jwalton

I have already made a work around in my project to pre-check _message content size, and shift it if oversize, before publish new data into the channel.

_.sumBy(channelWrapper._messages, 'content.length')

gwh-cpnet avatar Nov 27 '18 22:11 gwh-cpnet

We would need to completely disable the memory queuing and instead fail fast. We want our clients to stop sending requests as soon as rabbitMq is down. Do you plan to add this feature?

zatziky avatar Feb 18 '19 09:02 zatziky

If you have a PR that adds it in a clean way, I'd certainly merge it.

jwalton avatar Feb 19 '19 15:02 jwalton

You're right, I should add something to the community too. I will see if it's absolutely necessary. :D @jwalton

zatziky avatar Feb 19 '19 18:02 zatziky

I'm running into issues with the internal queue too, since it has issues handling high throughput and is always running behind causing the memory to fill up untill the app crashes. It would be a better idea only to use the internal _messages queue when the connections fails.

You can send messages directly by accessing _channel like this for example:

      channelWrapper._channel.sendToQueue(jobName(), new Buffer(EJSON.stringify(task)), options, (err) => {
        if (err) {
          channelWrapper.close()
          connection.close()
        }
      })

Pagebakers avatar Apr 08 '19 12:04 Pagebakers