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

**URL:** <https://community.solace.com/t/how-to-consume-messages-synchronously-from-a-solace-queue-via-spring-boot-application/1808>\
**Category:** Connectors & Integrations\
**Tags:** queue, springboot\
**Created:** [November 25, 2023, 8:39am UTC](https://community.solace.com/t/how-to-consume-messages-synchronously-from-a-solace-queue-via-spring-boot-application/1808 "2023-11-25T08:39:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pavithra](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/pavithra/32/900_2.png) [@Pavithra](https://community.solace.com/u/Pavithra)\
**Post date:** [November 25, 2023, 8:39am UTC](https://community.solace.com/t/how-to-consume-messages-synchronously-from-a-solace-queue-via-spring-boot-application/1808/1 "2023-11-25T08:39:43Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Pavithra](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/pavithra/32/900_2.png) [@Pavithra](https://community.solace.com/u/Pavithra)\
**Post date:** [November 27, 2023, 9:02am UTC](https://community.solace.com/t/how-to-consume-messages-synchronously-from-a-solace-queue-via-spring-boot-application/1808/2 "2023-11-27T09:02:50Z")

</div>

@hong requesting to assign someone to assist on my query… Thanks in advance ?

---

<div class="post-metadata">

**Author:** ![Tamimi](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/tamimi/32/2190_2.png) [@Tamimi](https://community.solace.com/u/Tamimi)\
**Post date:** [November 29, 2023, 7:22pm UTC](https://community.solace.com/t/how-to-consume-messages-synchronously-from-a-solace-queue-via-spring-boot-application/1808/3 "2023-11-29T19:22:19Z")

</div>

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 to `FLOW_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!

---

<div class="post-metadata">

**Author:** ![Pavithra](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/pavithra/32/900_2.png) [@Pavithra](https://community.solace.com/u/Pavithra)\
**Post date:** [November 30, 2023, 4:28am UTC](https://community.solace.com/t/how-to-consume-messages-synchronously-from-a-solace-queue-via-spring-boot-application/1808/4 "2023-11-30T04:28:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tamimi](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/tamimi/32/2190_2.png) [@Tamimi](https://community.solace.com/u/Tamimi)\
**Post date:** [November 30, 2023, 3:34pm UTC](https://community.solace.com/t/how-to-consume-messages-synchronously-from-a-solace-queue-via-spring-boot-application/1808/5 "2023-11-30T15:34:07Z")

</div>

Great to hear that! And glad you’re finding the community helpful ?
