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

nfilotto pushed a commit to branch CAMEL-17792/doc-message-headers
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5b2fe25c8e9bad4dfeda7640f1033d82e51771f6
Author: Nicolas Filotto <nfilo...@talend.com>
AuthorDate: Mon Apr 4 16:19:34 2022 +0200

    CAMEL-17792: Add doc about the message headers of camel-rabbitmq
---
 .../apache/camel/component/rabbitmq/rabbitmq.json  | 25 ++++++++
 .../src/main/docs/rabbitmq-component.adoc          | 72 +---------------------
 .../component/rabbitmq/RabbitMQConstants.java      | 43 +++++++++++++
 .../camel/component/rabbitmq/RabbitMQEndpoint.java |  2 +-
 .../rabbitmq/RabbitMQMessageConverter.java         |  2 +-
 5 files changed, 73 insertions(+), 71 deletions(-)

diff --git 
a/components/camel-rabbitmq/src/generated/resources/org/apache/camel/component/rabbitmq/rabbitmq.json
 
b/components/camel-rabbitmq/src/generated/resources/org/apache/camel/component/rabbitmq/rabbitmq.json
index 2d0bb30caf1..b3d17e0f98b 100644
--- 
a/components/camel-rabbitmq/src/generated/resources/org/apache/camel/component/rabbitmq/rabbitmq.json
+++ 
b/components/camel-rabbitmq/src/generated/resources/org/apache/camel/component/rabbitmq/rabbitmq.json
@@ -79,6 +79,31 @@
     "trustManager": { "kind": "property", "displayName": "Trust Manager", 
"group": "security", "label": "security", "required": false, "type": "object", 
"javaType": "javax.net.ssl.TrustManager", "deprecated": false, "autowired": 
false, "secret": false, "description": "Configure SSL trust manager, SSL should 
be enabled for this option to be effective" },
     "username": { "kind": "property", "displayName": "Username", "group": 
"security", "label": "security", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "defaultValue": "guest", "description": "Username in case of 
authenticated access" }
   },
+  "headers": {
+    "CamelRabbitmqRoutingKey": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "Consumer: The routing key that was used to receive the message, 
or the routing key that will be used when producing a message Producer: The 
routing key that will be used when sending the message" },
+    "CamelRabbitmqExchangeOverrideName": { "kind": "header", "displayName": 
"", "group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "Used for force sending the message to this exchange 
instead of the endpoint configured name on the producer" },
+    "CamelRabbitmqExchangeName": { "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "Consumer: The exchange the message was received from 
Producer: The exchange the message was received from" },
+    "CamelRabbitmqContentType": { "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The contentType to set on the RabbitMQ message" },
+    "CamelRabbitmqPriority": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "int", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The priority header to set on the RabbitMQ message" },
+    "CamelRabbitmqDeliveryTag": { "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "long", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The rabbitmq delivery tag of the received message" },
+    "CamelRabbitmqRedeliveryTag": { "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "boolean", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "Whether the message is a redelivered" },
+    "CamelRabbitmqCorrelationId": { "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The correlationId to set on the RabbitMQ message." },
+    "CamelRabbitmqMessageId": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The message id to set on the RabbitMQ message." },
+    "CamelRabbitmqDeliveryMode": { "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "Integer", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "If the message should be persistent or not" },
+    "CamelRabbitmqUserId": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The userId to set on the RabbitMQ message" },
+    "CamelRabbitmqClusterId": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The clusterId to set on the RabbitMQ message" },
+    "CamelRabbitmqRequestTimeout": { "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "long", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The timeout for waiting for a reply when using the InOut 
Exchange Pattern (in milliseconds)" },
+    "CamelRabbitmqReplyTo": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The replyTo to set on the RabbitMQ message" },
+    "CamelRabbitmqContentEncoding": { "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The contentEncoding to set on the RabbitMQ message" },
+    "CamelRabbitmqType": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The type to set on the RabbitMQ message" },
+    "CamelRabbitmqExpiration": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The expiration to set on the RabbitMQ message" },
+    "CamelRabbitmqTimestamp": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "java.util.Date", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The timestamp to set on the RabbitMQ message" },
+    "CamelRabbitmqAppId": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The appId to set on the RabbitMQ message" },
+    "CamelRabbitmqRequeue": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "boolean", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "This is used by the consumer to control rejection of the 
message. When the consumer is complete processing the exchange, and if the 
exchange failed, then the consumer is going to reject the message from the 
RabbitMQ broker. The value of this header contr [...]
+    "CamelRabbitmqMandatory": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "Boolean", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The flag telling the server how to react if the message cannot 
be routed to a queue." },
+    "CamelRabbitmqImmediate": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "Boolean", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The flag telling the server how to react if the message cannot 
be routed to a queue consumer immediately." },
+    "CamelMessageTimestamp": { "kind": "header", "displayName": "", "group": 
"common", "label": "", "required": false, "javaType": "long", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The timestamp of the RabbitMQ message" }
+  },
   "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." },
     "addresses": { "kind": "parameter", "displayName": "Addresses", "group": 
"common", "label": "common", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "If this option is set, camel-rabbitmq will try to create 
connection based on the setting of option addresses. The addresses value is a 
string which looks like server1:12345, server2:12345" },
diff --git a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc 
b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
index 5000e1219f2..3f001c97725 100644
--- a/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
+++ b/components/camel-rabbitmq/src/main/docs/rabbitmq-component.adoc
@@ -96,75 +96,9 @@ The `ConnectionFactory` is auto-detected by default, so you 
can just do
 
 In case you have multiple connection factories in your application or multiple 
connection factories in your registry, don't forget to set the 
`autoDetectConnectionFactory` to false.
 
-== Message Headers
-
-The following headers are set on exchanges when consuming messages.
-
-[width="100%",cols="10%,90%",options="header",]
-|===
-|Property |Value
-
-|`CamelRabbitmqRoutingKey` |The routing key that was used to receive the 
message, or the routing key
-that will be used when producing a message
-
-|`CamelRabbitmqExchangeName` |The exchange the message was received from
-
-|`CamelRabbitmqDeliveryTag` |The rabbitmq delivery tag of the received message
-
-|`CamelRabbitmqRedeliveryTag` |Whether the message is a redelivered
-
-|`CamelRabbitmqRequeue` |This is used by the consumer to control rejection of 
the
-message. When the consumer is complete processing the exchange, and if
-the exchange failed, then the consumer is going to reject the message
-from the RabbitMQ broker. The value of this header controls this
-behavior. If the value is false (by default) then the message is
-discarded/dead-lettered. If the value is true, then the message is
-re-queued. 
-|===
-
-The following headers are used by the producer. If these are set on the
-camel exchange then they will be set on the RabbitMQ message.
-
-[width="100%",cols="10%,90%",options="header",]
-|===
-|Property |Value
-
-|`CamelRabbitmqRoutingKey` |The routing key that will be used when sending the 
message
-
-|`CamelRabbitmqExchangeName` |The exchange the message was received from
-
-|`CamelRabbitmqExchangeOverrideName` |Used for force sending the message to 
this exchange instead of the endpoint configured name on the producer
-
-|`CamelRabbitmqContentType` |The contentType to set on the RabbitMQ message
-
-|`CamelRabbitmqPriority` |The priority header to set on the RabbitMQ message
-
-|`CamelRabbitmqCorrelationId` |The correlationId to set on the RabbitMQ message
-
-|`CamelRabbitmqMessageId` |The message id to set on the RabbitMQ message
-
-|`CamelRabbitmqDeliveryMode` |If the message should be persistent or not
-
-|`CamelRabbitmqUserId` |The userId to set on the RabbitMQ message
-
-|`CamelRabbitmqClusterId` |The clusterId to set on the RabbitMQ message
-
-|`CamelRabbitmqReplyTo` |The replyTo to set on the RabbitMQ message
-
-|`CamelRabbitmqContentEncoding` |The contentEncoding to set on the RabbitMQ 
message
-
-|`CamelRabbitmqType` |The type to set on the RabbitMQ message
-
-|`CamelRabbitmqExpiration` |The expiration to set on the RabbitMQ message
-
-|`CamelRabbitmqTimestamp` |The timestamp to set on the RabbitMQ message
-
-|`CamelRabbitmqAppId` |The appId to set on the RabbitMQ message
-|===
-
-Headers are set by the consumer once the message is received. The
-producer will also set the headers for downstream processors once the
-exchange has taken place.
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
 
 == Troubleshooting headers
 
diff --git 
a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConstants.java
 
b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConstants.java
index 06597f16db3..a99ef556283 100644
--- 
a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConstants.java
+++ 
b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConstants.java
@@ -20,30 +20,73 @@ import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.Metadata;
+
 public final class RabbitMQConstants {
 
+    @Metadata(description = "*Consumer:* The routing key that was used to 
receive the message, or the routing key\n" +
+                            "that will be used when producing a message\n " +
+                            "*Producer:* The routing key that will be used 
when sending the message",
+              javaType = "String")
     public static final String ROUTING_KEY = "CamelRabbitmqRoutingKey";
+    @Metadata(description = "Used for force sending the message to this 
exchange instead of the endpoint configured name on the producer",
+              javaType = "String")
     public static final String EXCHANGE_OVERRIDE_NAME = 
"CamelRabbitmqExchangeOverrideName";
+    @Metadata(description = "*Consumer:* The exchange the message was received 
from\n " +
+                            "*Producer:* The exchange the message was received 
from",
+              javaType = "String")
     public static final String EXCHANGE_NAME = "CamelRabbitmqExchangeName";
+    @Metadata(description = "The contentType to set on the RabbitMQ message", 
javaType = "String")
     public static final String CONTENT_TYPE = "CamelRabbitmqContentType";
+    @Metadata(description = "The priority header to set on the RabbitMQ 
message", javaType = "int")
     public static final String PRIORITY = "CamelRabbitmqPriority";
+    @Metadata(description = "The rabbitmq delivery tag of the received 
message", javaType = "long")
     public static final String DELIVERY_TAG = "CamelRabbitmqDeliveryTag";
+    @Metadata(description = "Whether the message is a redelivered", javaType = 
"boolean")
     public static final String REDELIVERY_TAG = "CamelRabbitmqRedeliveryTag";
+    @Metadata(description = "The correlationId to set on the RabbitMQ 
message.", javaType = "String")
     public static final String CORRELATIONID = "CamelRabbitmqCorrelationId";
+    @Metadata(description = "The message id to set on the RabbitMQ message.", 
javaType = "String")
     public static final String MESSAGE_ID = "CamelRabbitmqMessageId";
+    @Metadata(description = "If the message should be persistent or not", 
javaType = "Integer")
     public static final String DELIVERY_MODE = "CamelRabbitmqDeliveryMode";
+    @Metadata(description = "The userId to set on the RabbitMQ message", 
javaType = "String")
     public static final String USERID = "CamelRabbitmqUserId";
+    @Metadata(description = "The clusterId to set on the RabbitMQ message", 
javaType = "String")
     public static final String CLUSTERID = "CamelRabbitmqClusterId";
+    @Metadata(description = "The timeout for waiting for a reply when using 
the InOut Exchange Pattern (in milliseconds)",
+              javaType = "long")
     public static final String REQUEST_TIMEOUT = "CamelRabbitmqRequestTimeout";
+    @Metadata(description = "The replyTo to set on the RabbitMQ message", 
javaType = "String")
     public static final String REPLY_TO = "CamelRabbitmqReplyTo";
+    @Metadata(description = "The contentEncoding to set on the RabbitMQ 
message", javaType = "String")
     public static final String CONTENT_ENCODING = 
"CamelRabbitmqContentEncoding";
+    @Metadata(description = "The type to set on the RabbitMQ message", 
javaType = "String")
     public static final String TYPE = "CamelRabbitmqType";
+    @Metadata(description = "The expiration to set on the RabbitMQ message", 
javaType = "String")
     public static final String EXPIRATION = "CamelRabbitmqExpiration";
+    @Metadata(description = "The timestamp to set on the RabbitMQ message", 
javaType = "java.util.Date")
     public static final String TIMESTAMP = "CamelRabbitmqTimestamp";
+    @Metadata(description = "The appId to set on the RabbitMQ message", 
javaType = "String")
     public static final String APP_ID = "CamelRabbitmqAppId";
+    @Metadata(description = "This is used by the consumer to control rejection 
of the\n" +
+                            "message. When the consumer is complete processing 
the exchange, and if\n" +
+                            "the exchange failed, then the consumer is going 
to reject the message\n" +
+                            "from the RabbitMQ broker. The value of this 
header controls this\n" +
+                            "behavior. If the value is false (by default) then 
the message is\n" +
+                            "discarded/dead-lettered. If the value is true, 
then the message is\n" +
+                            "re-queued.",
+              javaType = "boolean")
     public static final String REQUEUE = "CamelRabbitmqRequeue";
+    @Metadata(description = "The flag telling the server how to react if the 
message cannot be routed to a queue.",
+              javaType = "Boolean")
     public static final String MANDATORY = "CamelRabbitmqMandatory";
+    @Metadata(description = "The flag telling the server how to react if the 
message cannot be routed to a queue consumer immediately.",
+              javaType = "Boolean")
     public static final String IMMEDIATE = "CamelRabbitmqImmediate";
+    @Metadata(description = "The timestamp of the RabbitMQ message", javaType 
= "long")
+    public static final String MESSAGE_TIMESTAMP = Exchange.MESSAGE_TIMESTAMP;
     public static final String RABBITMQ_DEAD_LETTER_EXCHANGE = 
"x-dead-letter-exchange";
     public static final String RABBITMQ_DEAD_LETTER_ROUTING_KEY = 
"x-dead-letter-routing-key";
     public static final String RABBITMQ_DIRECT_REPLY_EXCHANGE = "";
diff --git 
a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
 
b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
index 540898886c3..09e878b6671 100644
--- 
a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
+++ 
b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java
@@ -57,7 +57,7 @@ import static 
org.apache.camel.component.rabbitmq.RabbitMQComponent.QUEUE_ARG_PR
  * Send and receive messages from <a 
href="http://www.rabbitmq.com/";>RabbitMQ</a> instances.
  */
 @UriEndpoint(firstVersion = "2.12.0", scheme = "rabbitmq", title = "RabbitMQ", 
syntax = "rabbitmq:exchangeName",
-             category = { Category.MESSAGING })
+             category = { Category.MESSAGING }, headersClass = 
RabbitMQConstants.class)
 public class RabbitMQEndpoint extends DefaultEndpoint implements AsyncEndpoint 
{
     // header to indicate that the message body needs to be de-serialized
     public static final String SERIALIZE_HEADER = "CamelSerialize";
diff --git 
a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQMessageConverter.java
 
b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQMessageConverter.java
index 81443912f7a..7fe26390325 100644
--- 
a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQMessageConverter.java
+++ 
b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQMessageConverter.java
@@ -333,7 +333,7 @@ public class RabbitMQMessageConverter {
             }
         }
         if (properties.getTimestamp() != null) {
-            message.setHeader(Exchange.MESSAGE_TIMESTAMP, 
properties.getTimestamp().getTime());
+            message.setHeader(RabbitMQConstants.MESSAGE_TIMESTAMP, 
properties.getTimestamp().getTime());
         }
     }
 

Reply via email to