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

Options
Pavithra
Pavithra Member Posts: 7 ✭✭

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 βœ“
    Options

    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 ✭✭
    Options

    @hong requesting to assign someone to assist on my query.... Thanks in advance πŸ™‚

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 494 admin
    Options

    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 βœ“
    Options

    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: 494 admin
    Options

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