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 f52c6f308f2eafe7fa527f021885c71f8ccf3d97
Author: Nicolas Filotto <[email protected]>
AuthorDate: Tue Apr 5 18:56:38 2022 +0200

    CAMEL-17792: Add doc about the message headers of camel-timer
---
 .../org/apache/camel/component/timer/timer.json    |  4 +++
 .../camel-timer/src/main/docs/timer-component.adoc |  6 ++--
 .../camel/component/timer/TimerConstants.java      | 32 ++++++++++++++++++++++
 .../camel/component/timer/TimerConsumer.java       |  4 +--
 .../camel/component/timer/TimerEndpoint.java       |  2 +-
 5 files changed, 42 insertions(+), 6 deletions(-)

diff --git 
a/components/camel-timer/src/generated/resources/org/apache/camel/component/timer/timer.json
 
b/components/camel-timer/src/generated/resources/org/apache/camel/component/timer/timer.json
index 0979f5d03cc..e8f3c630442 100644
--- 
a/components/camel-timer/src/generated/resources/org/apache/camel/component/timer/timer.json
+++ 
b/components/camel-timer/src/generated/resources/org/apache/camel/component/timer/timer.json
@@ -25,6 +25,10 @@
     "bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error 
Handler", "group": "consumer", "label": "consumer", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "Allows for bridging the 
consumer to the Camel routing Error Handler, which mean any exceptions occurred 
while the consumer is trying to pickup incoming messages, or the likes, will 
now be processed as a me [...]
     "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": {
+    "firedTime": { "kind": "header", "displayName": "", "group": "consumer", 
"label": "", "required": false, "javaType": "Date", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": "The 
fired time" },
+    "CamelMessageTimestamp": { "kind": "header", "displayName": "", "group": 
"consumer", "label": "", "required": false, "javaType": "long", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The timestamp of the message" }
+  },
   "properties": {
     "timerName": { "kind": "path", "displayName": "Timer Name", "group": 
"consumer", "label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "The name of the timer" },
     "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error 
Handler", "group": "consumer", "label": "consumer", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "Allows for bridging the 
consumer to the Camel routing Error Handler, which mean any exceptions occurred 
while the consumer is trying to pickup incoming messages, or the likes, will 
now be processed as a m [...]
diff --git a/components/camel-timer/src/main/docs/timer-component.adoc 
b/components/camel-timer/src/main/docs/timer-component.adoc
index 458406340be..b163789c8f1 100644
--- a/components/camel-timer/src/main/docs/timer-component.adoc
+++ b/components/camel-timer/src/main/docs/timer-component.adoc
@@ -38,8 +38,6 @@ See also the xref:quartz-component.adoc[Quartz] component 
that supports much mor
 advanced scheduling.
 ====
 
-
-
 // component-configure options: START
 
 // component-configure options: END
@@ -52,7 +50,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
 
 == Exchange Properties
 
diff --git 
a/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConstants.java
 
b/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConstants.java
new file mode 100644
index 00000000000..92e81026ec0
--- /dev/null
+++ 
b/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConstants.java
@@ -0,0 +1,32 @@
+/*
+ * 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.timer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.Metadata;
+
+public final class TimerConstants {
+
+    @Metadata(description = "The fired time", javaType = "Date")
+    public static final String HEADER_FIRED_TIME = "firedTime";
+    @Metadata(description = "The timestamp of the message", javaType = "long")
+    public static final String HEADER_MESSAGE_TIMESTAMP = 
Exchange.MESSAGE_TIMESTAMP;
+
+    private TimerConstants() {
+
+    }
+}
diff --git 
a/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
 
b/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
index 815103a7bb6..4576fd23896 100644
--- 
a/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
+++ 
b/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
@@ -196,8 +196,8 @@ public class TimerConsumer extends DefaultConsumer 
implements StartupListener, S
             Date now = new Date();
             exchange.setProperty(Exchange.TIMER_FIRED_TIME, now);
             // also set now on in header with same key as quartz to be 
consistent
-            exchange.getIn().setHeader("firedTime", now);
-            exchange.getIn().setHeader(Exchange.MESSAGE_TIMESTAMP, 
now.getTime());
+            exchange.getIn().setHeader(TimerConstants.HEADER_FIRED_TIME, now);
+            
exchange.getIn().setHeader(TimerConstants.HEADER_MESSAGE_TIMESTAMP, 
now.getTime());
         }
 
         if (LOG.isTraceEnabled()) {
diff --git 
a/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java
 
b/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java
index b54346c960a..23415099603 100644
--- 
a/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java
+++ 
b/components/camel-timer/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java
@@ -41,7 +41,7 @@ import org.apache.camel.support.DefaultEndpoint;
  */
 @ManagedResource(description = "Managed TimerEndpoint")
 @UriEndpoint(firstVersion = "1.0.0", scheme = "timer", title = "Timer", syntax 
= "timer:timerName", consumerOnly = true,
-             category = { Category.CORE, Category.SCHEDULING })
+             category = { Category.CORE, Category.SCHEDULING }, headersClass = 
TimerConstants.class)
 public class TimerEndpoint extends DefaultEndpoint implements 
MultipleConsumersSupport {
     @UriPath
     @Metadata(required = true)

Reply via email to