davsclaus commented on code in PR #27760:
URL: https://github.com/apache/camel/pull/27760#discussion_r4255126304
##########
components/camel-box/camel-box-api/src/main/java/org/apache/camel/component/box/api/BoxEventLogsManager.java:
##########
@@ -80,15 +84,26 @@ public List<BoxEvent> getEnterpriseEvents(String position,
Date after, Date befo
}
EnterpriseEventsRequest request = new EnterpriseEventsRequest();
-
request.position(position).after(after).before(before).types(types);
- EventLog eventLog = EventLog.getEnterpriseEvents(boxConnection,
request);
+ request.after(after).before(before).types(types);
- List<BoxEvent> results = new ArrayList<>();
- for (BoxEvent event : eventLog) {
- results.add(event);
+ // The service returns the events in chunks (of at most 500
events) with the position of the next
+ // chunk. Read on from that position until a chunk is empty, which
is the end of the events within
+ // bounds. An event that the service returns in two chunks is kept
once.
+ Set<BoxEvent> results = new LinkedHashSet<>();
+ String streamPosition = position;
+ while (true) {
+ EventLog eventLog =
EventLog.getEnterpriseEvents(boxConnection, request.position(streamPosition));
+ for (BoxEvent event : eventLog) {
+ results.add(event);
+ }
+ String nextStreamPosition = eventLog.getNextStreamPosition();
+ if (eventLog.getSize() == 0 || nextStreamPosition == null ||
nextStreamPosition.equals(streamPosition)) {
Review Comment:
Minor, non-blocking: in box-java-sdk 4.16.4 the `EventLog` constructor does
`nextStreamPosition.isString() ? asString() : toString()`, so a JSON `null`
becomes the string `"null"` (and a missing key fails with an NPE inside the
SDK). The `== null` check is therefore never true. It's harmless because the
empty-chunk check is what ends the loop in practice, just mentioning it in case
you want the guard to be meaningful (e.g. also treat `"null"` as no position)
or drop it.
##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc:
##########
@@ -202,3 +202,10 @@ throttling): the failure of the first object is then the
failure of the poll, an
In both cases the objects are no longer kept in the `inProgressRepository`;
before, the object (or a new object with
the same key) was skipped by all later polls until the endpoint was restarted.
With the `fileName` option, a failed
get still fails the poll.
+
+=== camel-box
Review Comment:
Nit: the other 4.24 entries use a `component - what changed` heading;
something like this would match:
```suggestion
=== camel-box - getEnterpriseEvents returns the events of every chunk
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]