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 41917715fb5b2fdacf47a292380b3d61864d6043 Author: Nicolas Filotto <[email protected]> AuthorDate: Mon Apr 4 15:28:21 2022 +0200 CAMEL-17792: Add doc about the message headers of camel-pulsar --- .../org/apache/camel/component/pulsar/pulsar.json | 16 ++++++++++++++++ .../camel-pulsar/src/main/docs/pulsar-component.adoc | 4 +++- .../apache/camel/component/pulsar/PulsarEndpoint.java | 4 +++- .../apache/camel/component/pulsar/PulsarProducer.java | 2 +- .../pulsar/utils/message/PulsarMessageHeaders.java | 19 +++++++++++++++++++ 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/components/camel-pulsar/src/generated/resources/org/apache/camel/component/pulsar/pulsar.json b/components/camel-pulsar/src/generated/resources/org/apache/camel/component/pulsar/pulsar.json index c906ce93808..ba2c1bcf854 100644 --- a/components/camel-pulsar/src/generated/resources/org/apache/camel/component/pulsar/pulsar.json +++ b/components/camel-pulsar/src/generated/resources/org/apache/camel/component/pulsar/pulsar.json @@ -64,6 +64,22 @@ "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...] "pulsarClient": { "kind": "property", "displayName": "Pulsar Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.pulsar.client.api.PulsarClient", "deprecated": false, "autowired": true, "secret": false, "description": "The pulsar client" } }, + "headers": { + "properties": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "Map<String, String>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The properties attached to the message." }, + "producer_name": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The producer name who produced the message." }, + "sequence_id": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The sequence id associated with the message." }, + "publish_time": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The publish time of the message." }, + "message_id": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "org.apache.pulsar.client.api.MessageId", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The unique message ID associated with the message." }, + "event_time": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The event time associated with the message." }, + "key": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The key of the message." }, + "key_bytes": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "byte[]", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The bytes in key." }, + "topic_name": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The topic the message was published to." }, + "message_receipt": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "org.apache.camel.component.pulsar.PulsarMessageReceipt", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message receipt." }, + "CamelPulsarProducerMessageKey": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The key of the message for routing policy." }, + "CamelPulsarProducerMessageProperties": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Map<String, String>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The properties of the message to add." }, + "CamelPulsarProducerMessageEventTime": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The event time of the message message." }, + "CamelPulsarRedeliveryCount": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message redelivery count, redelivery count maintain in pulsar broker." } + }, "properties": { "persistence": { "kind": "path", "displayName": "Persistence", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "enum": [ "persistent", "non-persistent" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the topic is persistent or non-persistent" }, "tenant": { "kind": "path", "displayName": "Tenant", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The tenant" }, diff --git a/components/camel-pulsar/src/main/docs/pulsar-component.adoc b/components/camel-pulsar/src/main/docs/pulsar-component.adoc index 21b4c85086d..b278dc4cd54 100644 --- a/components/camel-pulsar/src/main/docs/pulsar-component.adoc +++ b/components/camel-pulsar/src/main/docs/pulsar-component.adoc @@ -44,7 +44,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: START // endpoint options: END - +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END include::spring-boot:partial$starter.adoc[] diff --git a/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarEndpoint.java b/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarEndpoint.java index ceba2ef4da8..131cece023c 100644 --- a/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarEndpoint.java +++ b/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarEndpoint.java @@ -20,6 +20,7 @@ import org.apache.camel.Category; import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; +import org.apache.camel.component.pulsar.utils.message.PulsarMessageHeaders; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; @@ -33,7 +34,8 @@ import org.apache.pulsar.client.api.PulsarClient; * Send and receive messages from/to Apache Pulsar messaging system. */ @UriEndpoint(scheme = "pulsar", firstVersion = "2.24.0", title = "Pulsar", - syntax = "pulsar:persistence://tenant/namespace/topic", category = { Category.MESSAGING }) + syntax = "pulsar:persistence://tenant/namespace/topic", category = { Category.MESSAGING }, + headersClass = PulsarMessageHeaders.class) public class PulsarEndpoint extends DefaultEndpoint { private PulsarClient pulsarClient; diff --git a/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarProducer.java b/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarProducer.java index 054868f85a6..52dcdc14dfb 100644 --- a/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarProducer.java +++ b/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarProducer.java @@ -56,7 +56,7 @@ public class PulsarProducer extends DefaultProducer { body = exchange.getContext().getTypeConverter() .mandatoryConvertTo(byte[].class, exchange, message.getBody()); } catch (NoTypeConversionAvailableException | TypeConversionException exception) { - // fallback to try serialize the data + // fallback to try to serialize the data body = PulsarMessageUtils.serialize(message.getBody()); } messageBuilder.value(body); diff --git a/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/utils/message/PulsarMessageHeaders.java b/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/utils/message/PulsarMessageHeaders.java index bf65ab1c4b1..204fd8e1c65 100644 --- a/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/utils/message/PulsarMessageHeaders.java +++ b/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/utils/message/PulsarMessageHeaders.java @@ -16,20 +16,39 @@ */ package org.apache.camel.component.pulsar.utils.message; +import org.apache.camel.spi.Metadata; + public interface PulsarMessageHeaders { + @Metadata(label = "consumer", description = "The properties attached to the message.", javaType = "Map<String, String>") String PROPERTIES = "properties"; + @Metadata(label = "consumer", description = "The producer name who produced the message.", javaType = "String") String PRODUCER_NAME = "producer_name"; + @Metadata(label = "consumer", description = "The sequence id associated with the message.", javaType = "long") String SEQUENCE_ID = "sequence_id"; + @Metadata(label = "consumer", description = "The publish time of the message.", javaType = "long") String PUBLISH_TIME = "publish_time"; + @Metadata(label = "consumer", description = "The unique message ID associated with the message.", + javaType = "org.apache.pulsar.client.api.MessageId") String MESSAGE_ID = "message_id"; + @Metadata(label = "consumer", description = "The event time associated with the message.", javaType = "long") String EVENT_TIME = "event_time"; + @Metadata(label = "consumer", description = "The key of the message.", javaType = "String") String KEY = "key"; + @Metadata(label = "consumer", description = "The bytes in key.", javaType = "byte[]") String KEY_BYTES = "key_bytes"; + @Metadata(label = "consumer", description = "The topic the message was published to.", javaType = "String") String TOPIC_NAME = "topic_name"; + @Metadata(label = "consumer", description = "The message receipt.", + javaType = "org.apache.camel.component.pulsar.PulsarMessageReceipt") String MESSAGE_RECEIPT = "message_receipt"; + @Metadata(label = "producer", description = "The key of the message for routing policy.", javaType = "String") String KEY_OUT = "CamelPulsarProducerMessageKey"; + @Metadata(label = "producer", description = "The properties of the message to add.", javaType = "Map<String, String>") String PROPERTIES_OUT = "CamelPulsarProducerMessageProperties"; + @Metadata(label = "producer", description = "The event time of the message message.", javaType = "Long") String EVENT_TIME_OUT = "CamelPulsarProducerMessageEventTime"; + @Metadata(label = "consumer", description = "The message redelivery count, redelivery count maintain in pulsar broker.", + javaType = "int") String PULSAR_REDELIVERY_COUNT = "CamelPulsarRedeliveryCount"; }
