Paul Richardson created CAMEL-13077:
---------------------------------------
Summary: Olingo4 Consumer appears to not work with
backoffIdleThreshold
Key: CAMEL-13077
URL: https://issues.apache.org/jira/browse/CAMEL-13077
Project: Camel
Issue Type: Bug
Components: camel-olingo4
Affects Versions: 2.23.0, 2.22.0, 2.21.0
Reporter: Paul Richardson
Looking into using {{backoffIdleThreshold}} for reducing the amount of polling
of OData consuming. So far I cannot see how it would work for the
[Olingo4Consumer|https://github.com/apache/camel/blob/master/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java].
Bear with me, this may get a little deep to follow!
Hierarchy: ScheduledPollConsumer > AbstractApiConsumer > Olingo4Consumer
SchedulePollConsumer maintains an
[idleCounter|https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java#L61],
which is incremented each time no messages are returned from polling. Once the
{{idleCounter}} starts to increment then this in turn starts to increment the
backoffCounter taking into account properties such as {{backoffIdleThreshold}},
resulting in delaying polling etc.
However, in order for {{idleCounter}} to increment, {{poll()}} methods must
return 0 messages. Since {{Olingo4Consumer}} defers its {{result[0]}} to
[ApiConsumer.getResultsProcessed()|https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/support/component/ApiConsumerHelper.java#L85],
the results must be in a form that can be handled by this static method,
namely a List, an Iterable or an Array. Otherwise, the result is merely added
to the Exchange and the constant '1' is returned.
Now here is the crux. OData services like to return a {{ClientEntitySet}} hence
when the result is passed to {{ApiConsumerHelper}}, it is none of the expected
types and
['1'|https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/support/component/ApiConsumerHelper.java#L128]
is therefore always returned. Consequently, the return value of {{poll()}} is
1 hence {{idleCounter}} is never incremented.
I hope that makes sense and if I have made a mistake then please let me know. I
think the way to handle this would be to put the entities of the
{{ClientEntitySet}} into the result rather than the set itself. That way
ApiConsumerHelper would understand a {{Collection}} as an {{Iterable}} and
return a proper value based on the size of the collection. Alternatively, if
the {{ClientEntitySet}} is desired as the result then maybe
{{ApiConsumerHelper}} needs to be extended in some way so as to correctly
handle a return value for {{poll()}}.
Not sure which way to go on this so anxious to start a discussion.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)