🎄 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.
Pause & Resume Solace Message consumption from a queue
Hi,
we have requirement, when a particular job is running we need to stop listening to a queue to consume new messages after that job is completed we want to start consuming the messages from Queue.
Using Solace Spring Cloud Stream how we can pause and resume consuming of messages from a queue.
if we have some code snippet to implement this in java will be helpful.
Thank you in advance
Comments
-
Hi @Ravi,
The Spring Cloud Stream Binder for Solace supports pausing/resuming bindings as defined by the Spring Cloud Stream framework. Can you check this out and see if it will work for you? It allows you to do it programmatically or via actuator.
0 -
@marc We are using 3.1.0 version for spring-cloud-starter-stream-solace, we can't see pausing/resuming consumer listener in this version.
Can you please let us know from which version this capability is available?
Also to pause or resume we need to get the object of Binding object to perform pause or resume consumer listener right? how can we get the Binding object, to perform pause and resume operations?
0 -
Hi @Ravi ,
Looking at the change log here that functionality was added in v3.3.0.
As for the binding it looks like you can get the
BindingsLifecycleController
bean from the application context and then get your bindings from there. Checkout the example in the Spring Cloud Stream reference guide under "Binding Visualization and control" -> "Programmatic way".Hope that helps!
0 -
Thanks @marc , after using the v3.3.0, I am able to pause and resume consuming of messages as per my need programmatically as below
BindingsLifecycleController bindingsController = applicationContext.getBean(BindingsLifecycleController.class);
Binding binding = bindingsController.queryState("binder-in-0");
log.info(binding.isPaused()); // false
bindingsController.changeState("binder-in-0", State.PAUSED);
log.info(binding.isPaused()); // true
bindingsController.changeState("binder-in-0", State.RESUMED);
log.info(binding.isPaused()); //false
1