You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2022/04/04 13:40:41 UTC

[camel] 04/08: CAMEL-17792: Add doc about the message headers of camel-pgevent

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 67088c81192724e724ae53d6d88f77eeaa764bd0
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Mon Apr 4 12:55:15 2022 +0200

    CAMEL-17792: Add doc about the message headers of camel-pgevent
---
 .../apache/camel/component/pgevent/pgevent.json    |  3 +++
 .../src/main/docs/pgevent-component.adoc           |  6 ++---
 .../camel/component/pgevent/PgEventConstants.java  | 29 ++++++++++++++++++++++
 .../camel/component/pgevent/PgEventConsumer.java   |  2 +-
 .../camel/component/pgevent/PgEventEndpoint.java   |  2 +-
 5 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/components/camel-pgevent/src/generated/resources/org/apache/camel/component/pgevent/pgevent.json b/components/camel-pgevent/src/generated/resources/org/apache/camel/component/pgevent/pgevent.json
index c7126a8ff07..bb9af110968 100644
--- a/components/camel-pgevent/src/generated/resources/org/apache/camel/component/pgevent/pgevent.json
+++ b/components/camel-pgevent/src/generated/resources/org/apache/camel/component/pgevent/pgevent.json
@@ -26,6 +26,9 @@
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...]
     "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 [...]
   },
+  "headers": {
+    "channel": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the channel." }
+  },
   "properties": {
     "host": { "kind": "path", "displayName": "Host", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "localhost", "description": "To connect using hostname and port to the database." },
     "port": { "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "5432", "description": "To connect using hostname and port to the database." },
diff --git a/components/camel-pgevent/src/main/docs/pgevent-component.adoc b/components/camel-pgevent/src/main/docs/pgevent-component.adoc
index db6885b4680..31d08a4edf1 100644
--- a/components/camel-pgevent/src/main/docs/pgevent-component.adoc
+++ b/components/camel-pgevent/src/main/docs/pgevent-component.adoc
@@ -54,6 +54,9 @@ include::partial$component-endpoint-options.adoc[]
 
 // endpoint options: END
 
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
 
 == Common problems
 
@@ -62,7 +65,4 @@ Using the driver provided by PostgreSQL itself (`jdbc:postgresql:/...`) when usi
 
 Please use the pgjdbc-ng driver (`jdbc:pgsql:/...`) instead.
 
-
-
-
 include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventConstants.java b/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventConstants.java
new file mode 100644
index 00000000000..86fab218e4f
--- /dev/null
+++ b/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventConstants.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.pgevent;
+
+import org.apache.camel.spi.Metadata;
+
+public final class PgEventConstants {
+
+    @Metadata(label = "consumer", description = "The name of the channel.", javaType = "String")
+    public static final String HEADER_CHANNEL = "channel";
+
+    private PgEventConstants() {
+
+    }
+}
diff --git a/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventConsumer.java b/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventConsumer.java
index aebe8e39f92..e0ce6dfe92e 100644
--- a/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventConsumer.java
+++ b/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventConsumer.java
@@ -61,7 +61,7 @@ public class PgEventConsumer extends DefaultConsumer implements PGNotificationLi
 
         Exchange exchange = createExchange(false);
         Message msg = exchange.getIn();
-        msg.setHeader("channel", channel);
+        msg.setHeader(PgEventConstants.HEADER_CHANNEL, channel);
         msg.setBody(payload);
 
         try {
diff --git a/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventEndpoint.java b/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventEndpoint.java
index 6ebad1f1fa0..1f0d672e34a 100644
--- a/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventEndpoint.java
+++ b/components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventEndpoint.java
@@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
  */
 @UriEndpoint(firstVersion = "2.15.0", scheme = "pgevent", title = "PostgresSQL Event",
              syntax = "pgevent:host:port/database/channel",
-             category = { Category.DATABASE, Category.SQL })
+             category = { Category.DATABASE, Category.SQL }, headersClass = PgEventConstants.class)
 public class PgEventEndpoint extends DefaultEndpoint {
 
     private static final Logger LOG = LoggerFactory.getLogger(PgEventEndpoint.class);