I am using stomp client on node.js with ActiveMQ. Currently the producer pushes the message into queue and if client (consumer) is connected then it consumes the message. If client is not connected then messages are pending in queue until or unless some consumer is connected.
In my case, each operation performed by consumer is expensive and can take up to 2 hours. I want to consume a message and then stop consuming messages from queue until that operation is complete. Currently as soon message is pushed into queue, client pulls all messages from queue automatically. What I want is to pull one message wait for its completion and then pull again from queue and so on. This is to avoid race conditions.
For example if I have three tasks in a queue: A | B | C
The current flow is that all messages are consumed in queue leaving it empty.
What I want is to consume 1 message i.e
A | B | (C is consumed)
Perform actions on C.
After everything is completed by consumer then take next message
A | (B is consumed)
And so on...
Reason for which I'm using ActiveMQ for communicating is that it is reliable for delivering messages if in case node app crashes, or my server is down etc.