🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

How to consume messages synchronously from a solace "Queue" via Spring boot application?

Hi Team

I am trying to develop an application where we connect to a Queue ( which is subscribing to multiple topics) and read message synchronously and make sure the next message is consumed only after current message is acknowledged.

I tried reading resources provided by solace documentation and found snippet available only to subscribe to a topic but not Queue.

I need an reference or simple code snippet to understand and develop the same.

Kindly help. Any sought of help is appreciated 🙂

Tagged:

Best Answer

  • Pavithra
    Pavithra Member Posts: 7 ✭✭
    #2 Answer ✓

    Hi @Tamimi

    Thanks for your prompt response 😃.

    But I was seeking for code snippet example (without using listener). Anyways I tried creating connection, session, consumer and applied recive() method to receive messages without opening any listener and it worked.


    Thanks for your support as always.

Answers

  • Pavithra
    Pavithra Member Posts: 7 ✭✭

    @hong requesting to assign someone to assist on my query.... Thanks in advance 🙂

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 541 admin

    Hey there @Pavithra ! I'll take a stab at this and mention there are multiple approaches for the desired behaviour you are attempting to achieve:

    • You can set the MAX_DELIVERED_UNACKNOWLEDGED_MSGS_PER_FLOW on the queue to set the maximum number of messages delivered but not acknowledged per flow for the Queue. In your case you want this set to 1
    • Set the FLOW_WINDOW_SIZE to 1 when binding to the queue from your application. This controls how many messages can leave the broker (i.e. queue) to the API/App at once.

    It is important to note that the MAX_DELIVERED_UNACKNOWLEDGED_MSGS_PER_FLOW should be greater than or equal toFLOW_WINDOW_SIZE

    There are a couple of community posts that would help with this if you want to dig further, but thats a starting point!

  • Pavithra
    Pavithra Member Posts: 7 ✭✭
    #5 Answer ✓

    Hi @Tamimi

    Thanks for your prompt response 😃.

    But I was seeking for code snippet example (without using listener). Anyways I tried creating connection, session, consumer and applied recive() method to receive messages without opening any listener and it worked.


    Thanks for your support as always.

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 541 admin

    Great to hear that! And glad you're finding the community helpful 😊