You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/03/14 03:15:32 UTC

[camel] 02/02: deliveryTag -> For manual ack

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

davsclaus pushed a commit to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4c315adf703f65810a134f16d18d128d4d3a4120
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Mar 14 04:14:28 2023 +0100

    deliveryTag -> For manual ack
---
 .../org/apache/camel/component/springrabbit/spring-rabbitmq.json | 3 ++-
 .../src/main/docs/spring-rabbitmq-component.adoc                 | 9 ++++-----
 .../camel/component/springrabbit/SpringRabbitMQConstants.java    | 3 ++-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/components/camel-spring-rabbitmq/src/generated/resources/org/apache/camel/component/springrabbit/spring-rabbitmq.json b/components/camel-spring-rabbitmq/src/generated/resources/org/apache/camel/component/springrabbit/spring-rabbitmq.json
index 248003c583e..44631fc3298 100644
--- a/components/camel-spring-rabbitmq/src/generated/resources/org/apache/camel/component/springrabbit/spring-rabbitmq.json
+++ b/components/camel-spring-rabbitmq/src/generated/resources/org/apache/camel/component/springrabbit/spring-rabbitmq.json
@@ -54,7 +54,8 @@
   },
   "headers": {
     "CamelSpringRabbitmqRoutingOverrideKey": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exchange key.", "constantName": "org.apache.camel.component.springrabbit.SpringRabbitMQConstants#ROUTING_OVERRIDE_KEY" },
-    "CamelSpringRabbitmqExchangeOverrideName": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exchange name.", "constantName": "org.apache.camel.component.springrabbit.SpringRabbitMQConstants#EXCHANGE_OVERRIDE_NAME" }
+    "CamelSpringRabbitmqExchangeOverrideName": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exchange name.", "constantName": "org.apache.camel.component.springrabbit.SpringRabbitMQConstants#EXCHANGE_OVERRIDE_NAME" },
+    "CamelSpringRabbitmqDeliveryTag": { "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Delivery tag for manual acknowledge mode", "constantName": "org.apache.camel.component.springrabbit.SpringRabbitMQConstants#DELIVERY_TAG" }
   },
   "properties": {
     "exchangeName": { "kind": "path", "displayName": "Exchange Name", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exchange name determines the exchange to which the produced messages will be sent to. In the case of consumers, the exchange name determines the exchange the queue will be bound to. Note: to use default exchange then do n [...]
diff --git a/components/camel-spring-rabbitmq/src/main/docs/spring-rabbitmq-component.adoc b/components/camel-spring-rabbitmq/src/main/docs/spring-rabbitmq-component.adoc
index a1c8fd82d08..131536af963 100644
--- a/components/camel-spring-rabbitmq/src/main/docs/spring-rabbitmq-component.adoc
+++ b/components/camel-spring-rabbitmq/src/main/docs/spring-rabbitmq-component.adoc
@@ -240,19 +240,18 @@ from("direct:order")
 
 == Manual Acknowledgement 
 
-If we need to manually acknowledge a message for some use case , we can 
+If we need to manually acknowledge a message for some use case  we can
 do it by setting and acknowledgeMode to Manual and using the below snippet
-of code to get Channel and deliveryTag to manually acknowledge the message
+of code to get Channel and deliveryTag to manually acknowledge the message:
 
 [source,java]
 ----
 from("spring-rabbitmq:%s?queues=%s&acknowledgeMode=MANUAL")
     .process(exchange -> {
         Channel channel = exchange.getProperty(SpringRabbitMQConstants.CHANNEL, Channel.class);
-        long deliveryTag = exchange.getIn().getHeader("deliveryTag",Long.class);
-         channel.basicAck(deliveryTag,false);
+        long deliveryTag = exchange.getMessage().getHeader(SpringRabbitMQConstants.DELIVERY_TAG, long.class);
+        channel.basicAck(deliveryTag, false);
     })
-
 ----
 
 
diff --git a/components/camel-spring-rabbitmq/src/main/java/org/apache/camel/component/springrabbit/SpringRabbitMQConstants.java b/components/camel-spring-rabbitmq/src/main/java/org/apache/camel/component/springrabbit/SpringRabbitMQConstants.java
index 634aef08ece..4518c39c3e8 100644
--- a/components/camel-spring-rabbitmq/src/main/java/org/apache/camel/component/springrabbit/SpringRabbitMQConstants.java
+++ b/components/camel-spring-rabbitmq/src/main/java/org/apache/camel/component/springrabbit/SpringRabbitMQConstants.java
@@ -27,6 +27,8 @@ public final class SpringRabbitMQConstants {
     public static final String ROUTING_OVERRIDE_KEY = "CamelSpringRabbitmqRoutingOverrideKey";
     @Metadata(description = "The exchange name.", javaType = "String")
     public static final String EXCHANGE_OVERRIDE_NAME = "CamelSpringRabbitmqExchangeOverrideName";
+    @Metadata(description = "Delivery tag for manual acknowledge mode", javaType = "long")
+    public static final String DELIVERY_TAG = "CamelSpringRabbitmqDeliveryTag";
     public static final String DIRECT_MESSAGE_LISTENER_CONTAINER = "DMLC";
     public static final String SIMPLE_MESSAGE_LISTENER_CONTAINER = "SMLC";
 
@@ -39,7 +41,6 @@ public final class SpringRabbitMQConstants {
     public static final String DELIVERY_LIMIT = "x-delivery-limit";
     public static final String EXPIRES = "x-expires";
     public static final String SINGLE_ACTIVE_CONSUMER = "x-single-active-consumer";
-    public static final String DELIVERY_TAG = "deliveryTag";
 
     private SpringRabbitMQConstants() {
         // Constants class