shashank created CAMEL-27210:
--------------------------------

             Summary: camel-box - the events consumer stops receiving events 
for good after Box could not be reached once, and routes an exchange without a 
body on every poll
                 Key: CAMEL-27210
                 URL: https://issues.apache.org/jira/browse/CAMEL-27210
             Project: Camel
          Issue Type: Bug
          Components: camel-box
            Reporter: shashank
            Assignee: shashank


h3. What happens

The {{box:events/listen}} consumer listens with the {{EventStream}} of the Box 
SDK. When a request of its poller thread fails (a network error, Box not 
reachable for longer than the SDK retries: the long poll, the {{OPTIONS 
/events}} of a new long poll URL, or the {{GET /events}} after a change), the 
exception ends the poller thread, and the SDK ({{EventStream.notifyException}}, 
box-java-sdk 4.16.4) stops the stream before it calls {{onException}} of the 
listeners. The return value of {{onException}} does not start it again; nothing 
does.

{{BoxConsumer.onException}} hands the exception to the exception handler (one 
WARN) and returns: from then on the consumer receives no event, and the route 
stays started until it is restarted. {{BoxConsumer.onNextPosition}} ignores the 
stream position, so the consumer could not continue where it was anyway.

h3. Also

{{BoxConsumer}} extends {{AbstractApiConsumer}}, a scheduled poll consumer, and 
does not override {{poll()}}: every poll (500 ms by default) invokes the 
{{listen}} method again without a listener, which does nothing 
({{BoxEventsManager.listen}} logs at DEBUG that the listener is missing), and 
routes an exchange with a {{null}} body for that {{void}} result. The route 
gets an empty message twice a second besides the events.

h3. How to reproduce

{{BoxEventsConsumerTest}} (camel-box-component): a {{BoxAPIConnection}} with a 
request interceptor answers as the service does (long poll URL, {{new_change}}, 
the events after a stream position) and fails a {{GET /events}} with the 
exception the SDK throws for a network error. The event of that request is 
never routed. Without any event, the route still receives exchanges without a 
body.

h3. Fix

{{BoxConsumer}} keeps the next stream position it is given, and when the event 
stream fails it listens again after a delay (1 s, doubled up to 60 s while it 
keeps failing, back to 1 s once events are received), from the position after 
the last events received, or from the {{startingPosition}} of the endpoint 
before any. A stop cancels a pending restart. {{BoxConsumer.poll()}} routes 
nothing and marks the consumer ready.

_Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to