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

davsclaus 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 5858273f0a28 CAMEL-27323: camel-ignite - a route from one 
ignite-messaging topic to another sends to the topic of the producer (#30570)
5858273f0a28 is described below

commit 5858273f0a28b316424c1a62ece3dcca2c1f5e93
Author: allthingssecurity <[email protected]>
AuthorDate: Sun Nov 22 19:08:37 2026 +0530

    CAMEL-27323: camel-ignite - a route from one ignite-messaging topic to 
another sends to the topic of the producer (#30570)
    
    The ignite-messaging consumer sets the CamelIgniteMessagingTopic header to
    the topic it received a message on, and the producer sent to the topic of
    that header instead of the topic of its endpoint. A route from one topic
    to another sent each message back to the first topic, where the consumer
    received it again, for ever, and the second topic got nothing.
    
    The consumer now also sets the exchange property
    CamelIgniteMessagingReceivedTopic to the received topic, and the producer
    uses the topic header only when it differs from that property (a topic
    chosen by the route), as camel-azure-eventhubs does with its received
    partition properties. Component page and 4.24 upgrade guide updated.
    
    The component page showed only the Java form,
    .removeProperty(IgniteConstants.IGNITE_MESSAGING_RECEIVED_TOPIC). It now 
also shows the
    removeProperty step with the name CamelIgniteMessagingReceivedTopic for 
YAML and XML.
    The catalog copy of the page is updated the same way.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../catalog/docs/ignite-messaging-component.adoc   |   9 ++
 .../src/main/docs/ignite-messaging-component.adoc  |   9 ++
 .../camel/component/ignite/IgniteConstants.java    |   4 +
 .../ignite/messaging/IgniteMessagingConsumer.java  |   1 +
 .../ignite/messaging/IgniteMessagingProducer.java  |  10 +-
 .../ignite/IgniteMessagingBridgeTest.java          | 125 +++++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    |  10 ++
 7 files changed, 167 insertions(+), 1 deletion(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ignite-messaging-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ignite-messaging-component.adoc
index 80f8ab8a3eb5..fb93a9b51dc9 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ignite-messaging-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ignite-messaging-component.adoc
@@ -43,3 +43,12 @@ The producer sends the body to the `orders` topic, and the 
consumer receives the
         - log:
             message: "Received: ${body}"
 ----
+
+The consumer sets the `CamelIgniteMessagingTopic` header to the topic it 
received a message on. While the header still
+holds that topic, the producer sends to the topic of its endpoint, so a route 
from one topic to another sends each
+message to the second topic, not back to the first one. A topic header set by 
the route is used. To send a received
+message back to its topic through the header, remove the 
`CamelIgniteMessagingReceivedTopic` exchange property (which
+the consumer sets to the received topic) before the producer, such as with
+`.removeProperty(IgniteConstants.IGNITE_MESSAGING_RECEIVED_TOPIC)` in Java. 
The property name is
+`CamelIgniteMessagingReceivedTopic`, so in YAML it is a `removeProperty` step 
with
+`name: CamelIgniteMessagingReceivedTopic`, and in XML `<removeProperty 
name="CamelIgniteMessagingReceivedTopic"/>`.
diff --git 
a/components/camel-ignite/src/main/docs/ignite-messaging-component.adoc 
b/components/camel-ignite/src/main/docs/ignite-messaging-component.adoc
index 80f8ab8a3eb5..fb93a9b51dc9 100644
--- a/components/camel-ignite/src/main/docs/ignite-messaging-component.adoc
+++ b/components/camel-ignite/src/main/docs/ignite-messaging-component.adoc
@@ -43,3 +43,12 @@ The producer sends the body to the `orders` topic, and the 
consumer receives the
         - log:
             message: "Received: ${body}"
 ----
+
+The consumer sets the `CamelIgniteMessagingTopic` header to the topic it 
received a message on. While the header still
+holds that topic, the producer sends to the topic of its endpoint, so a route 
from one topic to another sends each
+message to the second topic, not back to the first one. A topic header set by 
the route is used. To send a received
+message back to its topic through the header, remove the 
`CamelIgniteMessagingReceivedTopic` exchange property (which
+the consumer sets to the received topic) before the producer, such as with
+`.removeProperty(IgniteConstants.IGNITE_MESSAGING_RECEIVED_TOPIC)` in Java. 
The property name is
+`CamelIgniteMessagingReceivedTopic`, so in YAML it is a `removeProperty` step 
with
+`name: CamelIgniteMessagingReceivedTopic`, and in XML `<removeProperty 
name="CamelIgniteMessagingReceivedTopic"/>`.
diff --git 
a/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/IgniteConstants.java
 
b/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/IgniteConstants.java
index 6866766432fe..032ae09b5961 100644
--- 
a/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/IgniteConstants.java
+++ 
b/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/IgniteConstants.java
@@ -65,6 +65,10 @@ public final class IgniteConstants {
                             "(consumer) It also carries the topic on which a 
message was received.",
               javaType = "String", applicableFor = SCHEME_MESSAGING)
     public static final String IGNITE_MESSAGING_TOPIC = 
"CamelIgniteMessagingTopic";
+    // exchange property the consumer sets to the topic a message was received 
on, so that the producer can tell the topic
+    // header the consumer sets apart from a topic chosen by the route. A 
route that wants to send a received message back
+    // to its topic with the header removes the property.
+    public static final String IGNITE_MESSAGING_RECEIVED_TOPIC = 
"CamelIgniteMessagingReceivedTopic";
     @Metadata(label = "consumer",
               description = "This header is filled in with the UUID of the 
subscription when a message arrives.",
               javaType = "java.util.UUID", applicableFor = SCHEME_MESSAGING)
diff --git 
a/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/messaging/IgniteMessagingConsumer.java
 
b/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/messaging/IgniteMessagingConsumer.java
index fc211673a7fe..98c7fcc0e0df 100644
--- 
a/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/messaging/IgniteMessagingConsumer.java
+++ 
b/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/messaging/IgniteMessagingConsumer.java
@@ -48,6 +48,7 @@ public class IgniteMessagingConsumer extends DefaultConsumer {
                 Message in = exchange.getIn();
                 in.setBody(payload);
                 in.setHeader(IgniteConstants.IGNITE_MESSAGING_TOPIC, 
endpoint.getTopic());
+                
exchange.setProperty(IgniteConstants.IGNITE_MESSAGING_RECEIVED_TOPIC, 
endpoint.getTopic());
                 in.setHeader(IgniteConstants.IGNITE_MESSAGING_UUID, uuid);
                 if (LOG.isTraceEnabled()) {
                     LOG.trace("Processing Ignite message for subscription {} 
with payload {}.", uuid, payload);
diff --git 
a/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/messaging/IgniteMessagingProducer.java
 
b/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/messaging/IgniteMessagingProducer.java
index f05e537c1926..1809b7fcc2f9 100644
--- 
a/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/messaging/IgniteMessagingProducer.java
+++ 
b/components/camel-ignite/src/main/java/org/apache/camel/component/ignite/messaging/IgniteMessagingProducer.java
@@ -66,7 +66,15 @@ public class IgniteMessagingProducer extends 
DefaultAsyncProducer {
     }
 
     private String topicFor(Exchange exchange) {
-        return 
exchange.getIn().getHeader(IgniteConstants.IGNITE_MESSAGING_TOPIC, 
endpoint.getTopic(), String.class);
+        String topic = 
exchange.getIn().getHeader(IgniteConstants.IGNITE_MESSAGING_TOPIC, 
String.class);
+        // a header still holding the topic an ignite-messaging consumer 
received the message on describes that
+        // message, it is not a topic chosen by the route: a route from one 
topic to another must not send the message
+        // back to the topic it came from (where the consumer receives it 
again)
+        if (topic == null
+                || 
topic.equals(exchange.getProperty(IgniteConstants.IGNITE_MESSAGING_RECEIVED_TOPIC,
 String.class))) {
+            return endpoint.getTopic();
+        }
+        return topic;
     }
 
 }
diff --git 
a/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteMessagingBridgeTest.java
 
b/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteMessagingBridgeTest.java
new file mode 100644
index 000000000000..9d209fec243f
--- /dev/null
+++ 
b/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteMessagingBridgeTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.ignite;
+
+import java.io.Serializable;
+import java.time.Duration;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.ignite.messaging.IgniteMessagingComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+
+/**
+ * A route from one ignite-messaging topic to another: the consumer sets the 
topic header to the topic it received the
+ * message on, and the producer must send to the topic of its endpoint, not 
back to that topic.
+ */
+class IgniteMessagingBridgeTest extends AbstractIgniteTest implements 
Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private final transient List<UUID> listeners = new 
CopyOnWriteArrayList<>();
+
+    @Override
+    protected String getScheme() {
+        return "ignite-messaging";
+    }
+
+    @Override
+    protected AbstractIgniteComponent createComponent() {
+        return 
IgniteMessagingComponent.fromConfiguration(createConfiguration());
+    }
+
+    @Test
+    void routeFromOneTopicToAnotherSendsToTheTopicOfTheProducer() throws 
Exception {
+        String from = "from-" + resourceUid;
+        String to = "to-" + resourceUid;
+        List<Object> onFrom = listen(from);
+        List<Object> onTo = listen(to);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("ignite-messaging:" + from).routeId("bridge")
+                        .to("mock:bridged")
+                        .to("ignite-messaging:" + to);
+            }
+        });
+        MockEndpoint bridged = getMockEndpoint("mock:bridged");
+        bridged.expectedBodiesReceived("hello");
+        bridged.setAssertPeriod(1000);
+
+        ignite().message().send(from, "hello");
+
+        await().atMost(Duration.ofSeconds(10)).until(() -> onTo.size() == 1);
+        // the route got the message once: it was not sent back to the topic 
it came from
+        bridged.assertIsSatisfied();
+        await().during(Duration.ofMillis(500)).atMost(Duration.ofSeconds(5))
+                .until(() -> onFrom.size() == 1 && onTo.size() == 1);
+    }
+
+    @Test
+    void topicHeaderSetByTheRouteIsUsed() throws Exception {
+        String from = "from-" + resourceUid;
+        String to = "to-" + resourceUid;
+        String other = "other-" + resourceUid;
+        List<Object> onTo = listen(to);
+        List<Object> onOther = listen(other);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("ignite-messaging:" + from).routeId("header")
+                        .setHeader(IgniteConstants.IGNITE_MESSAGING_TOPIC, 
constant(other))
+                        .to("ignite-messaging:" + to);
+            }
+        });
+
+        ignite().message().send(from, "hello");
+
+        await().atMost(Duration.ofSeconds(10)).until(() -> onOther.size() == 
1);
+        await().during(Duration.ofMillis(500)).atMost(Duration.ofSeconds(5))
+                .until(() -> onOther.size() == 1 && onTo.isEmpty());
+    }
+
+    private List<Object> listen(String topic) {
+        List<Object> messages = new CopyOnWriteArrayList<>();
+        listeners.add(ignite().message().remoteListen(topic, new 
IgniteBiPredicate<UUID, Object>() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public boolean apply(UUID nodeId, Object message) {
+                messages.add(message);
+                return true;
+            }
+        }));
+        return messages;
+    }
+
+    @AfterEach
+    void stopListeners() {
+        for (UUID listener : listeners) {
+            ignite().message().stopRemoteListen(listener);
+        }
+        listeners.clear();
+    }
+}
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 9cb87b0374fd..cbb7a138efd6 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -8853,6 +8853,16 @@ the element for `ADD`, `CONTAINS`, `REMOVE` and 
`RETAIN_ALL` of `ignite-queue` a
 `PUT` of `ignite-queue`. Before, these failed with a `NullPointerException`. 
The `GET`, `GET_AND_INCREMENT` and
 `INCREMENT_AND_GET` operations of `ignite-idgen` no longer fail on a body that 
is not a number, as they do not use it.
 
+=== camel-ignite - a route from one ignite-messaging topic to another sends to 
the topic of the producer
+
+The `ignite-messaging` producer sent to the topic named in the 
`CamelIgniteMessagingTopic` header, which the
+`ignite-messaging` consumer sets to the topic it received the message on. So a 
route from one topic to another
+(`from("ignite-messaging:orders").to("ignite-messaging:audit")`) sent each 
message back to the first topic, where the
+consumer received it again, for ever. The producer now sends to the topic of 
its endpoint while the header still holds
+the topic the message was received on (the consumer sets the new 
`CamelIgniteMessagingReceivedTopic` exchange property to
+that topic); a topic header set by the route is still used. To send a received 
message back to its topic through the
+header, remove the `CamelIgniteMessagingReceivedTopic` property before the 
producer.
+
 === camel-couchbase - the document id, the operation option and the bodies of 
CCB_PUT
 
 The `couchbase` producer now uses the `key` option as the document id when the 
message has no `CamelCouchbaseId`

Reply via email to