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

spyroid
spyroid Member Posts: 8

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

Tagged:

Best Answers

  • TomF
    TomF Member, Employee Posts: 412 Solace Employee
    #2 Answer ✓

    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.

  • nram
    nram Member, Employee Posts: 80 Solace Employee
    edited January 2021 #3 Answer ✓

    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.

Answers

  • TomF
    TomF Member, Employee Posts: 412 Solace Employee
    #4 Answer ✓

    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.

  • spyroid
    spyroid Member Posts: 8
    edited January 2021 #5

    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()

  • nram
    nram Member, Employee Posts: 80 Solace Employee
    edited January 2021 #6 Answer ✓

    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.

  • TomF
    TomF Member, Employee Posts: 412 Solace Employee

    @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.

  • spyroid
    spyroid Member Posts: 8
    edited January 2021 #8

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

  • TomF
    TomF Member, Employee Posts: 412 Solace Employee

    Glad to hear it @spyroid. If you're happy with the answer could you "accept" it? Thanks!

  • spyroid
    spyroid Member Posts: 8

    Sure I can, but I didn't see any button "Accept" :)

  • hong
    hong Guest Posts: 480 ✭✭✭✭✭

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