allthingssecurity commented on code in PR #27644:
URL: https://github.com/apache/camel/pull/27644#discussion_r4236665999
##########
components/camel-jooq/src/main/java/org/apache/camel/component/jooq/JooqConsumer.java:
##########
@@ -97,6 +114,7 @@ public int processBatch(Queue<Object> exchanges) throws
Exception {
for (int i = 0; i < total; i++) {
DataHolder holder =
org.apache.camel.util.ObjectHelper.cast(DataHolder.class, exchanges.poll());
getProcessor().process(holder.exchange);
+ holder.consumed = !holder.exchange.isFailed() &&
!holder.exchange.isRollbackOnly();
Review Comment:
Confirmed with a pooled test and fixed in 4984690: `createExchange(false)`,
the try/catch from `JpaConsumer` (the caught exception is also passed to the
consumer's exception handler, as nothing else would log it), the outcome read,
then `releaseExchange(exchange, false)`.
_Claude Code on behalf of allthingssecurity_
##########
components/camel-jooq/src/main/java/org/apache/camel/component/jooq/JooqConsumer.java:
##########
@@ -97,6 +114,7 @@ public int processBatch(Queue<Object> exchanges) throws
Exception {
for (int i = 0; i < total; i++) {
Review Comment:
Done in 4984690: the loop is now `for (int index = 0; index < total &&
isBatchAllowed(); index++)`, so the remaining entities of a batch stay in the
table when a graceful shutdown starts mid-batch;
`testNotProcessedEntitiesKeepRows` still passes and the upgrade guide entry
says so in one clause.
_Claude Code on behalf of allthingssecurity_
##########
components/camel-jooq/src/test/java/org/apache/camel/component/jooq/JooqConsumerDeleteFailedTest.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jooq;
+
+import java.util.List;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.ShutdownRunningTask;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jooq.db.tables.records.AuthorRecord;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.component.jooq.db.Tables.AUTHOR;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * With consumeDelete (the default) an entity must only be deleted when its
exchange was processed successfully: a
+ * failed or rollback only exchange, or an entity that was not processed, must
leave the row in the table, so the next
+ * poll consumes it again.
+ */
+class JooqConsumerDeleteFailedTest extends BaseJooqTest {
Review Comment:
Added `JooqConsumerDeleteFailedPooledExchangeTest` in 4984690 (subclass
overriding `createCamelContext()` with `PooledExchangeFactory`). On the
previous head 47a32ee the failed and rollback-only cases fail with `expected:
<[2]> but was: <[]>`; with the fix all three pass.
_Claude Code on behalf of allthingssecurity_
--
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]