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:30 UTC

[camel] branch camel-3.x updated (0b6629d1235 -> 4c315adf703)

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

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


    from 0b6629d1235 [CAMEL-18870] Error while generating OSGi manifest (#9523)
     new 680cc9082bc deliveryTag -> For manual ack (#9471)
     new 4c315adf703 deliveryTag -> For manual ack

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/springrabbit/spring-rabbitmq.json    |  3 ++-
 .../src/main/docs/spring-rabbitmq-component.adoc         | 16 ++++++++++++++++
 .../springrabbit/DefaultMessagePropertiesConverter.java  |  3 +++
 .../component/springrabbit/SpringRabbitMQConstants.java  |  2 ++
 4 files changed, 23 insertions(+), 1 deletion(-)


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

Posted by da...@apache.org.
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


[camel] 01/02: deliveryTag -> For manual ack (#9471)

Posted by da...@apache.org.
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 680cc9082bc57735e708945636bda86b2f3006ed
Author: mayurvaid-redvest <10...@users.noreply.github.com>
AuthorDate: Mon Mar 13 22:48:00 2023 +0530

    deliveryTag -> For manual ack (#9471)
    
    * deliveryTag -> For manual ack
    
    * Adding DELIVERY_TAG as constant
    
    * Referring DELIVERY_TAG constants
    
    * Adding readme docs for manual acknowledgement
    
    * Fixing checkstyle
---
 .../src/main/docs/spring-rabbitmq-component.adoc        | 17 +++++++++++++++++
 .../springrabbit/DefaultMessagePropertiesConverter.java |  3 +++
 .../component/springrabbit/SpringRabbitMQConstants.java |  1 +
 3 files changed, 21 insertions(+)

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 40a88a0e29e..a1c8fd82d08 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
@@ -238,5 +238,22 @@ from("direct:order")
   .toD("spring-rabbit:order-${header.orderType}");
 ----
 
+== Manual Acknowledgement 
+
+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
+
+[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);
+    })
+
+----
+
 
 include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-spring-rabbitmq/src/main/java/org/apache/camel/component/springrabbit/DefaultMessagePropertiesConverter.java b/components/camel-spring-rabbitmq/src/main/java/org/apache/camel/component/springrabbit/DefaultMessagePropertiesConverter.java
index 3d0ce92174a..8f72aa5d912 100644
--- a/components/camel-spring-rabbitmq/src/main/java/org/apache/camel/component/springrabbit/DefaultMessagePropertiesConverter.java
+++ b/components/camel-spring-rabbitmq/src/main/java/org/apache/camel/component/springrabbit/DefaultMessagePropertiesConverter.java
@@ -71,6 +71,9 @@ public class DefaultMessagePropertiesConverter implements MessagePropertiesConve
             if (messageProperties.getTimestamp() != null) {
                 answer.put(Exchange.MESSAGE_TIMESTAMP, messageProperties.getTimestamp().getTime());
             }
+
+            // Helps in getting to acknowledge manually
+            answer.put(SpringRabbitMQConstants.DELIVERY_TAG, messageProperties.getDeliveryTag());
         }
 
         return answer;
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 7e51f6384e7..634aef08ece 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
@@ -39,6 +39,7 @@ 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