Skip to content

Request to delay consumer and listener container shutdown to wait for pending reply messages when using Request/Reply Messaging with a fixed name reply queue. #3031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dldiehl77 opened this issue Mar 25, 2025 · 2 comments

Comments

@dldiehl77
Copy link
Contributor

Expected Behavior

When using the Request/Reply Messaging feature, a request message is sent, but before the reply message is received, the application starts a graceful shutdown (think of the case when running in a container orchestration platform and it decides that it wants to stop your container). Would like the consumer and listener container to wait for a reply message -- up to some configurable amount of time (something short, like 30 seconds). We always set an expiration TTL on the request message while calling the template method convertSendAndReceive, so a timeout on that synchronous call is the other possible outcome.

Current Behavior

Right now when the graceful shutdown commences, the consumer and listener container shut down quickly, presumably because there are no messages on the reply queue. The reply message does not yet exist.

Context

Our request messages are the result of customer interaction. They cause processing to happen in a remote location. The reply message is used to indicate successful processing back to a customer. Our orchestration platform periodically decides to stop a container (or one stops when we deploy a new version of software) and those currently executing instances sometimes have in-flight request messages that are awaiting reply messages. When the container stops without receiving the reply message, that message is lost, and we have to report a system error to the customer.

Artem noted on stackoverflow.com a possible workaround using a temporary queue name for each request/reply, but I'd really, really like to stick with fixed named queue to solve this issue.

@artembilan
Copy link
Member

@artembilan
Copy link
Member

I see a ListenerContainerAware contract which is consulted in the SimpleMessageListenerContainer.
So, we can use that hook to get access into the active state of the listener when we are in stopping phase for the listener container.
This way we may wait for that shutdownTimeout to let those pending replies to arrive during that window.

Feel free to try to contribute that fix or share any other thoughts.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants