shashank created CAMEL-27321:
--------------------------------
Summary: camel-jms, camel-sjms - an InOut request registered or
timed out around the reply manager stop is never completed (follow-up of
CAMEL-24124)
Key: CAMEL-27321
URL: https://issues.apache.org/jira/browse/CAMEL-27321
Project: Camel
Issue Type: Bug
Components: camel-jms, camel-sjms
Reporter: shashank
Assignee: shashank
h3. What happens
CAMEL-24124 completes the exchanges that wait for a reply when the reply
manager stops ({{CorrelationTimeoutMap.doStop}} drains the map). A few
exchanges are still never completed, so a synchronous caller waits for ever and
the exchange stays in flight:
* a request registered between the drain and the {{map.clear()}} of
{{DefaultTimeoutMap.doStop}} (cleared without an event), or after the stop (it
stays in the stopped map, whose purge task is cancelled). {{JmsProducer}}
checks {{isRunAllowed()}} once and registers the reply later, from the
{{MessageCreator}};
* with {{useMessageIDAsCorrelationID}}, {{updateCorrelationId}} removes the
handler and puts it back under the JMSMessageID, and the drain can run in
between;
* at stop the drained handlers are handed to the onTimeout executor; when their
continuations take longer than {{shutdownAwaitTermination}}, the forced
shutdown drops the queued tasks;
* with {{camel.threadpool.rejectedPolicy=Abort}} and a full queue, a timeout
task is rejected after its entry was removed from the map, and
{{DefaultTimeoutMap.emitEvent}} swallows the exception without a log.
h3. How to reproduce
A reply manager set up as {{JmsProducer}} does (no broker needed), with the
thread orders forced through the map's listener events: register during or
after the stop, move a handler after the drain, stop with a busy onTimeout
thread and a short {{shutdownAwaitTermination}}, or time out three requests on
a pool of one thread with a queue of one and the Abort policy. In each case an
exchange is never completed.
Found with a TLA+ model of the JMS request-reply correlation.
h3. Fix
Close the correlation map under its lock before the drain: refuse a new request
({{RejectedExecutionException}}, the producer completes the exchange and does
not send it) and complete a moved handler at once. Run each timeout task once:
in the calling thread when the executor rejects it, and from the reply manager
after the executor shutdown when the executor never ran it. Log an exception of
a timeout map listener at WARN. Same in camel-jms and camel-sjms.
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)