Repository navigation
feat: let request and reply expire when the requester stops waiting - #85
Draft
GreenRover wants to merge 6 commits into
Draft
GreenRover wants to merge 6 commits into
GreenRover wants to merge 6 commits into
Conversation
A request nobody answered in time, or a reply that came too late, stayed on a persistent queue without a time-to-live and was processed long after the requester had given up. The request now carries the timeout as its Solace time-to-live, and a reply what is left of it on the responder's clock. Closes #84
A message arrives with the time-to-live its sender set, not with what is left of it: JCSMP derives the end of life at sending and does not hand it on while a time-to-live is set. The reply's time-to-live is therefore an upper bound, longer by as long as the request waited to be delivered.
A responder cannot know what is left of the request's time-to-live, so computing a remaining time bought a few seconds for clock and timestamp logic. The reply's time-to-live is now set after the caller's headers, so that it never lands next to an expiration the caller gave.
JCSMP refuses a time-to-live above ten years, so a caller that passed a huge timeout to wait forever could no longer send its request. The changelog now lists the expiry as a change in behaviour, and the README says what an interceptor and a request forwarded from Solace get.
A request whose timeout ran out before a worker picked it up was never sent, so verifying the send after a 100 ms timeout could fail on a busy agent. The docs now say what a forwarded Solace message, an error reply and a custom time-to-live parser get.
The time-to-live parsers were public API with a single, Solace-only implementation, while writing the lifetime is Solace-only anyway. A parser for another binder would have read its time-to-live only to write it into a Solace header that binder ignores.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #84
What
The request/reply timeout now also sets the Solace time-to-live (
solace_timeToLive) of the exchange:wrap,wrapListandwrapFluxtakes the request's time-to-live unchanged. That includes grouped, terminal and error replies. A request without a time-to-live gets replies without one, so a mix of old and new versions behaves as before.A request nobody answered in time, or a reply that came too late, no longer waits on a persistent queue to be processed after the requester gave up. A reply lives at most one timeout after it was sent.
Design decisions to review
expiration) is derived only locally at sending and is not sent while a TTL is set (resetExpirationBinaryMeta). A remaining time would need a deadline from the requester and would depend on the clocks agreeing, for a gain of a few seconds.solace_timeToLivekeeps it. The sources are a requestMessage,additionalHeaders, a message interceptor, orcopyHeadersOnWrap. To opt out per request, passsolace_timeToLive = 0LinadditionalHeaders.solace_expirationgets no TTL added. On awrapreply the TTL is set afteradditionalHeaders, so an expiration given there is seen. A message interceptor runs last and sees the TTL; one that setssolace_expirationhas to remove it (documented).solace_timeToLiveandsolace_expirationon every inbound message, 0 if unset. Forwarded as a request, such a message keeps that lifetime; the README says to remove both headers to get the timeout. Treating a 0 value as "no lifetime" would make the explicit opt-outsolace_timeToLive = 0Lindistinguishable from it.wraptake the request's TTL.additionalHeadersnever applied to the error reply of a forwarded exception, and still do not.MessageTimeToLiveis the only place that reads and writessolace_timeToLiveandsolace_expiration. Writing is Solace-only, so a pluggable read side would buy nothing. AGENTS.md §6 names this as the one exception to "header access goes through the parser chain". The change adds no public API apart fromMessageTimeToLive.respect-ttlenabled. If an application relied on a responder working through requests after the requester gave up, it has to passsolace_timeToLive = 0L. The CHANGELOG lists this under Changed. Whether that needs a major version (AGENTS.md §4) is the maintainer's call;pom.xmlis untouched. Direct messages are not affected. For a non-Solace binder, the request carries one extrasolace_timeToLiveheader.- Expired messages go to the DMQ, if there is one. The Solace binder marks messages DMQ-eligible by default (solace_dmqEligible). Where a queue has a dead message queue, expired requests and replies collect there instead of disappearing. The library leavessolace_dmqEligiblealone; the DMQ is the operator's choice.defaultHeaderTTL is overridden. The binder applies the producerdefaultHeaderfirst and the message headers on top. Asolace_timeToLiveconfigured there, which is the workaround the issue names, is therefore replaced by the library's value. README and CHANGELOG point toadditionalHeadersor an interceptor instead.pom.xmlis unchanged. The CHANGELOG entry is under[Unreleased].doc/spec.yamlis deliberately unchanged: it lists user headers, and the time-to-live is a field of the Solace message.Tests
RequestReplySimpleServiceTests, five tests. The mocked send answers at once, so no test waits for a timeout, and a request cannot time out before it is sent:Longtime-to-live, blocking and reactive;additionalHeaderswins;solace_expirationgets no time-to-live.RequestReplySimpleMessageHeaderSupportServiceTests, eight tests:wrap, on the error reply, on groupedwrapList, and on everywrapFluxreply including the finishing one;additionalHeaderswin;additionalHeadersgive an expiration.MessageTimeToLiveTests: a time-to-live below 1 ms is written as 1 ms, and one above ten years (ChronoUnit.FOREVER) as ten years.wrap, error reply, groupedwrapList,wrapFlux)wrapcopies it beforeadditionalHeadersadditionalHeaders)wrapList,wrapFlux)MessageTimeToLiveTests)MessageTimeToLiveTests)additionalHeaderson request and reply, request message)solace_expirationignoredadditionalHeaders)mvn -Dgpg.skip verify: BUILD SUCCESS. 109 tests ran, with 0 failures, 0 errors and 0 skipped. The new code adds no Javadoc warnings.