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 10acfe8db11bc781d8f54b935f7ae0bce58dbdbe
Author: Nicolas Filotto <[email protected]>
AuthorDate: Wed Mar 16 16:17:58 2022 +0100

    CAMEL-17792: Add doc about the message headers of camel-azure-eventhubs
---
 .../component/azure/eventhubs/azure-eventhubs.json |  9 +++++++
 .../src/main/docs/azure-eventhubs-component.adoc   | 24 +++---------------
 .../azure/eventhubs/EventHubsConstants.java        | 29 ++++++++++++++++++++++
 .../azure/eventhubs/EventHubsConsumer.java         |  2 +-
 .../azure/eventhubs/EventHubsEndpoint.java         |  3 ++-
 5 files changed, 44 insertions(+), 23 deletions(-)

diff --git 
a/components/camel-azure/camel-azure-eventhubs/src/generated/resources/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json
 
b/components/camel-azure/camel-azure-eventhubs/src/generated/resources/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json
index 5dedd45..8039758 100644
--- 
a/components/camel-azure/camel-azure-eventhubs/src/generated/resources/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json
+++ 
b/components/camel-azure/camel-azure-eventhubs/src/generated/resources/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json
@@ -43,6 +43,15 @@
     "sharedAccessKey": { "kind": "property", "displayName": "Shared Access 
Key", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": true, "configurationClass": 
"org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", 
"configurationField": "configuration", "description": "The generated value for 
the SharedAccessName" },
     "sharedAccessName": { "kind": "property", "displayName": "Shared Access 
Name", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", 
"configurationField": "configuration", "description": "The name you chose for 
your EventHubs SAS keys" }
   },
+  "headers": {
+    "CamelAzureEventHubsPartitionKey": { "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "(producer) Overrides the hashing key to be provided for 
the batch of events, which instructs the Event Hubs service to map this key to 
a specific partition.\n(consumer) It sets the partition hashing key if it was 
set when originally publishing  [...]
+    "CamelAzureEventHubsPartitionId": { "kind": "header", "displayName": "", 
"group": "common", "label": "", "required": false, "javaType": "String", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "(producer) Overrides the identifier of the Event Hub 
partition that the events will be sent to.\n(consumer) It sets the partition id 
of the Event Hub." },
+    "CamelAzureEventHubsOffset": { "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"Integer", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "It sets the offset of the event when it was 
received from the associated Event Hub partition. This is only present on a 
received `EventData`." },
+    "CamelAzureEventHubsEnqueuedTime": { "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"Instant", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "It sets the instant, in UTC, of when the event 
was enqueued in the Event Hub partition. This is only present on a received 
`EventData`." },
+    "CamelAzureEventHubsSequenceNumber": { "kind": "header", "displayName": 
"", "group": "consumer", "label": "consumer", "required": false, "javaType": 
"Long", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "It sets the sequence number assigned to the 
event when it was enqueued in the associated Event Hub partition. This is 
unique for every message received in the Event Hub partition. This is only 
present on a received `EventData`." },
+    "CamelAzureEventHubsMetadata": { "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"Map<String, Object>", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "The set of free-form event properties 
which may be used for passing metadata associated with the event with the event 
body during Event Hubs operations." },
+    "CamelMessageTimestamp": { "kind": "header", "displayName": "", "group": 
"consumer", "label": "consumer", "required": false, "javaType": "long", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The timestamp of the message" }
+  },
   "properties": {
     "namespace": { "kind": "path", "displayName": "Namespace", "group": 
"common", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", 
"configurationField": "configuration", "description": "EventHubs namespace 
created in Azure Portal" },
     "eventHubName": { "kind": "path", "displayName": "Event Hub Name", 
"group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", 
"configurationField": "configuration", "description": "EventHubs name under a 
specific namcespace" },
diff --git 
a/components/camel-azure/camel-azure-eventhubs/src/main/docs/azure-eventhubs-component.adoc
 
b/components/camel-azure/camel-azure-eventhubs/src/main/docs/azure-eventhubs-component.adoc
index 16f4c73..b958e2e 100644
--- 
a/components/camel-azure/camel-azure-eventhubs/src/main/docs/azure-eventhubs-component.adoc
+++ 
b/components/camel-azure/camel-azure-eventhubs/src/main/docs/azure-eventhubs-component.adoc
@@ -105,27 +105,9 @@ 
from("azure-eventhubs:/camel/camelHub?sharedAccessName=SASaccountName&sharedAcce
   .to("file://queuedirectory");
 
--------------------------------------------------------------------------------
 
-=== Message headers evaluated by the component producer
-[width="100%",cols="10%,10%,10%,70%",options="header",]
-|=======================================================================
-|Header |Variable Name |Type |Description
-
-|`CamelAzureEventHubsPartitionKey`| 
`EventHubsConstants.PARTITION_KEY`|`String`| Overrides the hashing key to be 
provided for the batch of events, which instructs the Event Hubs service to map 
this key to a specific partition.
-|`CamelAzureEventHubsPartitionId`| `EventHubsConstants.PARTITION_ID`|`String`| 
Overrides the identifier of the Event Hub partition that the {link EventData 
events} will be sent to.
-|=======================================================================
-
-
-=== Message headers set by the component consumer
-[width="100%",cols="10%,10%,10%,70%",options="header",]
-|=======================================================================
-|Header |Variable Name |Type |Description
-
-|`CamelAzureEventHubsPartitionKey`| 
`EventHubsConstants.PARTITION_KEY`|`String`| It sets the partition hashing key 
if it was set when originally publishing the event. If it exists, this value 
was used to compute a hash to select a partition to send the message to. This 
is only present on a received {@link EventData}.
-|`CamelAzureEventHubsPartitionId`| `EventHubsConstants.PARTITION_ID`|`String`| 
It sets the partition id of the Event Hub.
-|`CamelAzureEventHubsOffset`| `EventHubsConstants.OFFSET`|`Long`| It sets the 
offset of the event when it was received from the associated Event Hub 
partition. This is only present on a received {@link EventData}.
-|`CamelAzureEventHubsEnqueuedTime`| 
`EventHubsConstants.ENQUEUED_TIME`|`Instant`| It sets the instant, in UTC, of 
when the event was enqueued in the Event Hub partition. This is only present on 
a received {@link EventData}.
-|`CamelAzureEventHubsSequenceNumber`| 
`EventHubsConstants.SEQUENCE_NUMBER`|`Long`| It sets the sequence number 
assigned to the event when it was enqueued in the associated Event Hub 
partition. This is unique for every message received in the Event Hub 
partition. This is only present on a received {@link EventData}.
-|=======================================================================
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
 
 === Message body type
 The component's producer expects the data in the message body to be in 
`byte[]`. This allows the user to utilize Camel TypeConverter to 
marshal/unmarshal data with ease.
diff --git 
a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConstants.java
 
b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConstants.java
index cea1a32..889377d 100644
--- 
a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConstants.java
+++ 
b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConstants.java
@@ -16,16 +16,45 @@
  */
 package org.apache.camel.component.azure.eventhubs;
 
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.Metadata;
+
 public final class EventHubsConstants {
     private static final String HEADER_PREFIX = "CamelAzureEventHubs";
     // common headers, set by consumer and evaluated by producer
+    @Metadata(description = "(producer) Overrides the hashing key to be 
provided for the batch of events, which instructs the Event Hubs service to map 
this key to a specific partition.\n"
+                            +
+                            "(consumer) It sets the partition hashing key if 
it was set when originally publishing the event. "
+                            +
+                            "If it exists, this value was used to compute a 
hash to select a partition to send the message to. This is only present on a 
received `EventData`.",
+              javaType = "String")
     public static final String PARTITION_KEY = HEADER_PREFIX + "PartitionKey";
+    @Metadata(description = "(producer) Overrides the identifier of the Event 
Hub partition that the events will be sent to.\n"
+                            +
+                            "(consumer) It sets the partition id of the Event 
Hub.",
+              javaType = "String")
     public static final String PARTITION_ID = HEADER_PREFIX + "PartitionId";
     // headers set by the consumer only
+    @Metadata(label = "consumer",
+              description = "It sets the offset of the event when it was 
received from the associated Event Hub partition. This is only present on a 
received `EventData`.",
+              javaType = "Integer")
     public static final String OFFSET = HEADER_PREFIX + "Offset";
+    @Metadata(label = "consumer",
+              description = "It sets the instant, in UTC, of when the event 
was enqueued in the Event Hub partition. This is only present on a received 
`EventData`.",
+              javaType = "Instant")
     public static final String ENQUEUED_TIME = HEADER_PREFIX + "EnqueuedTime";
+    @Metadata(label = "consumer",
+              description = "It sets the sequence number assigned to the event 
when it was enqueued in the associated Event Hub partition. "
+                            +
+                            "This is unique for every message received in the 
Event Hub partition. This is only present on a received `EventData`.",
+              javaType = "Long")
     public static final String SEQUENCE_NUMBER = HEADER_PREFIX + 
"SequenceNumber";
+    @Metadata(label = "consumer",
+              description = "The set of free-form event properties which may 
be used for passing metadata associated with the event with the event body 
during Event Hubs operations.",
+              javaType = "Map<String, Object>")
     public static final String METADATA = HEADER_PREFIX + "Metadata";
+    @Metadata(label = "consumer", description = "The timestamp of the 
message", javaType = "long")
+    public static final String MESSAGE_TIMESTAMP = Exchange.MESSAGE_TIMESTAMP;
 
     private EventHubsConstants() {
     }
diff --git 
a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConsumer.java
 
b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConsumer.java
index 8411707..ef32303 100644
--- 
a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConsumer.java
+++ 
b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConsumer.java
@@ -87,7 +87,7 @@ public class EventHubsConsumer extends DefaultConsumer {
         message.setHeader(EventHubsConstants.SEQUENCE_NUMBER, 
eventContext.getEventData().getSequenceNumber());
         if (eventContext.getEventData().getEnqueuedTime() != null) {
             long ts = 
eventContext.getEventData().getEnqueuedTime().getEpochSecond() * 1000;
-            message.setHeader(Exchange.MESSAGE_TIMESTAMP, ts);
+            message.setHeader(EventHubsConstants.MESSAGE_TIMESTAMP, ts);
         }
         message.setHeader(EventHubsConstants.METADATA, 
eventContext.getEventData().getProperties());
 
diff --git 
a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpoint.java
 
b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpoint.java
index 6699aa1..b6a2bfa 100644
--- 
a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpoint.java
+++ 
b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpoint.java
@@ -30,7 +30,8 @@ import org.apache.camel.support.DefaultEndpoint;
  */
 @UriEndpoint(firstVersion = "3.5.0", scheme = "azure-eventhubs", title = 
"Azure Event Hubs",
              syntax = "azure-eventhubs:namespace/eventHubName", category = {
-                     Category.CLOUD, Category.MESSAGING })
+                     Category.CLOUD, Category.MESSAGING },
+             headersClass = EventHubsConstants.class)
 public class EventHubsEndpoint extends DefaultEndpoint {
 
     @UriParam

Reply via email to