I am using stompit package of node.js to connect to AMQ queue to subscribe message. I used ConnectFailover
class to create connection and channelPool
class to create pool.
Problem I am facing is that once connection is made and if there is no message in the queue then it stay connected.
What I need a way to disconnect if there is no message to read from the queue. I don't see any option in stompit documentation.
There is no way to do that with STOMP as per this issue. As a general rule, brokers like AMQ rarely allow consumers to inspect queue properties like message count.
Unless you can somehow leverage JMX from your node.js code, the easiest way would be to create a timer with client.disconnect()
as a callback and wait for an amount of time suitable for your system. Whenever a message is consumed, reset the timer.