JCSMP: Disconnect flow consumer from Queue to make possible other to connect

Hi. I need to unbind flow consumer from queue to make possible to run other app for connecting to the same queue.

Hi @spyroid, well you can just call .close() on the flow (if you’re using Java, for instance).
Alternatively, if you don’t need to worry about the order of the messages, you could change the queue type to “non-exclusive.” This would allow multiple applications to read from the same queue at the same time - which of course means message ordering can’t be guaranteed.

The queue is already configured to have only one subscriber. But how to start the subscriber on App1 again? I did tried to close() but got an error when was trying to start()

Hi @spyroid , you can call session.createFlow() multiple times and each time a new flow receiver with different FlowId will be created. These can be independently started/stopped and closed. With exclusive queue, the first flow receiver receives all the messages until it is closed. Then messages are sent to the next flow receiver and so on. With non-exclusive queue, as @TomF said, messages will be distributed across flow receivers.

@spyroid, ah, I think I see the problem. .close() destroys the flow - you need to re-create it and use that new flow going forward.

Yes, the approach with creating Flow and close it is working. Thanks

Glad to hear it @spyroid. If you’re happy with the answer could you “accept” it? Thanks!

Sure I can, but I didn’t see any button “Accept” :slight_smile:

@spyroid I’ve changed the post from discussion to question. You can now click Yes to accept Tom’s answer.