This is an automated email from the ASF dual-hosted git repository.

apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new c88eaf84101f CAMEL-24930: camel-core - Resequence EIP docs should say 
that the first of duplicate messages is kept
c88eaf84101f is described below

commit c88eaf84101f754e12c5dc3220b1313ed3972d95
Author: smjain <[email protected]>
AuthorDate: Wed Sep 23 17:12:41 2026 +0530

    CAMEL-24930: camel-core - Resequence EIP docs should say that the first of 
duplicate messages is kept
    
    The docs said that, without allowDuplicates, the resequencer keeps the last
    message when several messages have the same sequence expression. Both the
    batch and the stream resequencer keep the first one and drop the later ones
    (they use a TreeSet, which ignores an element equal to one it already
    holds), and BatchResequencerWithDuplicateTest asserts that. Fix the docs,
    and add a test for the stream mode.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../apache/camel/catalog/docs/resequence-eip.adoc  |  5 ++-
 .../docs/modules/eips/pages/resequence-eip.adoc    |  5 ++-
 .../processor/ResequenceStreamDuplicateTest.java   | 48 ++++++++++++++++++++++
 3 files changed, 54 insertions(+), 4 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/resequence-eip.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/resequence-eip.adoc
index aa9a08b4a160..ad9cde872263 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/resequence-eip.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/resequence-eip.adoc
@@ -26,7 +26,8 @@ Camel supports two re-sequencing algorithms:
 * xref:batchConfig-eip.adoc[Batch Resequencing] - *Default mode*: collects 
messages into a batch, sorts the messages and sends them to their output.
 * xref:streamConfig-eip.adoc[Stream Resequencing] - re-orders (continuous) 
message streams based on the detection of gaps between messages.
 
-By default, the Resequencer does not support duplicate messages and will only 
keep the last message, in case a message arrives with the same message 
expression.
+By default, the Resequencer does not support duplicate messages. If a message 
arrives with the same message expression as
+a message the Resequencer already holds, it keeps the message that arrived 
first and drops the later one.
 However, in the batch mode you can enable it to allow duplicates.
 
 == Options
@@ -205,7 +206,7 @@ This reorders messages using a custom sequence number with 
the header name mySeq
 === Allow Duplicates
 
 When allowing duplicates, then the resequencer retains the duplicate message 
instead
-of keeping only the last duplicated message.
+of keeping only the first message.
 
 In batch mode, you can turn on duplicates as follows:
 
diff --git 
a/core/camel-core-engine/src/main/docs/modules/eips/pages/resequence-eip.adoc 
b/core/camel-core-engine/src/main/docs/modules/eips/pages/resequence-eip.adoc
index aa9a08b4a160..ad9cde872263 100644
--- 
a/core/camel-core-engine/src/main/docs/modules/eips/pages/resequence-eip.adoc
+++ 
b/core/camel-core-engine/src/main/docs/modules/eips/pages/resequence-eip.adoc
@@ -26,7 +26,8 @@ Camel supports two re-sequencing algorithms:
 * xref:batchConfig-eip.adoc[Batch Resequencing] - *Default mode*: collects 
messages into a batch, sorts the messages and sends them to their output.
 * xref:streamConfig-eip.adoc[Stream Resequencing] - re-orders (continuous) 
message streams based on the detection of gaps between messages.
 
-By default, the Resequencer does not support duplicate messages and will only 
keep the last message, in case a message arrives with the same message 
expression.
+By default, the Resequencer does not support duplicate messages. If a message 
arrives with the same message expression as
+a message the Resequencer already holds, it keeps the message that arrived 
first and drops the later one.
 However, in the batch mode you can enable it to allow duplicates.
 
 == Options
@@ -205,7 +206,7 @@ This reorders messages using a custom sequence number with 
the header name mySeq
 === Allow Duplicates
 
 When allowing duplicates, then the resequencer retains the duplicate message 
instead
-of keeping only the last duplicated message.
+of keeping only the first message.
 
 In batch mode, you can turn on duplicates as follows:
 
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/processor/ResequenceStreamDuplicateTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/processor/ResequenceStreamDuplicateTest.java
new file mode 100644
index 000000000000..e14f9d70f25b
--- /dev/null
+++ 
b/core/camel-core/src/test/java/org/apache/camel/processor/ResequenceStreamDuplicateTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+/**
+ * The stream resequencer keeps the first of the messages with the same 
sequence number, as documented.
+ */
+public class ResequenceStreamDuplicateTest extends ContextTestSupport {
+
+    @Test
+    public void testDuplicateKeepsFirst() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("A1", "B");
+
+        template.sendBodyAndHeader("direct:start", "B", "seqno", 2);
+        template.sendBodyAndHeader("direct:start", "A1", "seqno", 1);
+        template.sendBodyAndHeader("direct:start", "A2", "seqno", 1);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                
from("direct:start").resequence(header("seqno")).stream().timeout(2000).to("mock:result");
+            }
+        };
+    }
+}

Reply via email to