[ 
https://issues.apache.org/jira/browse/CAMEL-25275?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved CAMEL-25275.
---------------------------------
    Resolution: Fixed

> camel-consul - the key/value and event consumers stop watching for good after 
> one failed query, while the route stays started
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25275
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25275
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-consul
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>             Fix For: 4.23.0
>
>
> The {{consul:kv}} and {{consul:event}} consumers watch with a chain of 
> blocking queries: the callback of each query 
> ({{ConsulResponseCallback.onComplete}} / 
> {{EventResponseCallback.onComplete}}) processes the answer and starts the 
> next query. The failure callback only reports the exception:
> {code:java}
> @Override
> public void onFailure(Throwable throwable) {
>     onError(throwable);   // exception handler, nothing else
> }
> {code}
> So when a single query fails (the Consul agent restarts, a network error, a 
> 500 while the Consul cluster has no leader, a read timeout), no further query 
> is started: the consumer receives no change anymore, for good, while the 
> route stays started. Only one WARN line from the exception handler shows it.
> h3. Reproduction
> Unit tests with a mocked {{Consul}} client ({{consulClient=#consul}}):
> * {{ConsulKeyValueWatchTest}}: the first {{getValue}} fails with 
> {{ConsulException}}: main never calls {{getValue}} again ({{Wanted 2 times 
> ... But was 1 time}}); with the fix the second query answers and the value 
> reaches the route.
> * {{ConsulEventWatchTest}}: the same for {{listEvents}}.
> h3. Proposed fix
> * {{ConsulKeyValueConsumer}}: after a failure, query the key again after 
> {{blockSeconds}} (at least one second, so that an agent that is down is not 
> queried in a loop), on a single-thread scheduler of the consumer (started and 
> shut down with it, as {{ConsulEventConsumer}} already does).
> * {{ConsulEventConsumer}}: after a failure, schedule the next query as after 
> an answer (its {{watch()}} already waits {{blockSeconds}}, see CAMEL-12418).
> Both only while the consumer runs. With the fix the two tests pass and the 
> camel-consul unit tests pass (6; the 27 ITs need Docker). {{mockito-core}} is 
> added as a test dependency.
> Affected: 4.14.x, 4.18.x and main (same code since 2017).
> Duplicate check (2026-10-02): JIRA component camel-consul and text "consul" 
> (90 issues): watch related are CAMEL-12418 (CPU load, the scheduling delay), 
> CAMEL-12511 (NPE on start), CAMEL-10073; none about failures. GitHub pull 
> requests "consul consumer": none.
> _Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to