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/05 16:14:51 UTC
[camel] 04/20: CAMEL-17792: Add doc about the message headers of camel-scheduler
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 2ecbed7d5b24f6762e07318dff114bea95b8a08b
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Tue Apr 5 10:29:48 2022 +0200
CAMEL-17792: Add doc about the message headers of camel-scheduler
---
.../camel/component/scheduler/scheduler.json | 3 +++
.../src/main/docs/scheduler-component.adoc | 4 ++-
.../component/scheduler/SchedulerConstants.java | 30 ++++++++++++++++++++++
.../component/scheduler/SchedulerConsumer.java | 2 +-
.../component/scheduler/SchedulerEndpoint.java | 2 +-
5 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/components/camel-scheduler/src/generated/resources/org/apache/camel/component/scheduler/scheduler.json b/components/camel-scheduler/src/generated/resources/org/apache/camel/component/scheduler/scheduler.json
index 816ed4bb60d..082bb111caa 100644
--- a/components/camel-scheduler/src/generated/resources/org/apache/camel/component/scheduler/scheduler.json
+++ b/components/camel-scheduler/src/generated/resources/org/apache/camel/component/scheduler/scheduler.json
@@ -26,6 +26,9 @@
"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 [...]
"poolSize": { "kind": "property", "displayName": "Pool Size", "group": "scheduler", "label": "scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1, "description": "Number of core threads in the thread pool used by the scheduling thread pool. Is by default using a single thread" }
},
+ "headers": {
+ "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": {
"name": { "kind": "path", "displayName": "Name", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the scheduler" },
"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-scheduler/src/main/docs/scheduler-component.adoc b/components/camel-scheduler/src/main/docs/scheduler-component.adoc
index 72f4b92eee8..8926b2821ce 100644
--- a/components/camel-scheduler/src/main/docs/scheduler-component.adoc
+++ b/components/camel-scheduler/src/main/docs/scheduler-component.adoc
@@ -50,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
== More information
diff --git a/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerConstants.java b/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerConstants.java
new file mode 100644
index 00000000000..56bbd5436d0
--- /dev/null
+++ b/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerConstants.java
@@ -0,0 +1,30 @@
+/*
+ * 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.scheduler;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.Metadata;
+
+public final class SchedulerConstants {
+
+ @Metadata(description = "The timestamp of the message", javaType = "long")
+ public static final String MESSAGE_TIMESTAMP = Exchange.MESSAGE_TIMESTAMP;
+
+ private SchedulerConstants() {
+
+ }
+}
diff --git a/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerConsumer.java b/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerConsumer.java
index bea04d66214..d869b76c239 100644
--- a/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerConsumer.java
+++ b/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerConsumer.java
@@ -56,7 +56,7 @@ public class SchedulerConsumer extends ScheduledPollConsumer {
Date now = new Date();
exchange.setProperty(Exchange.TIMER_FIRED_TIME, now);
- exchange.getIn().setHeader(Exchange.MESSAGE_TIMESTAMP, now.getTime());
+ exchange.getIn().setHeader(SchedulerConstants.MESSAGE_TIMESTAMP, now.getTime());
if (LOG.isTraceEnabled()) {
LOG.trace("Timer {} is firing", getEndpoint().getName());
diff --git a/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerEndpoint.java b/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerEndpoint.java
index b460e5a0684..e5d33df54b5 100644
--- a/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerEndpoint.java
+++ b/components/camel-scheduler/src/main/java/org/apache/camel/component/scheduler/SchedulerEndpoint.java
@@ -35,7 +35,7 @@ import org.apache.camel.support.ScheduledPollEndpoint;
* component uses JDK ScheduledExecutorService. Where as the timer uses a JDK Timer.
*/
@UriEndpoint(firstVersion = "2.15.0", scheme = "scheduler", title = "Scheduler", syntax = "scheduler:name",
- consumerOnly = true, category = { Category.CORE, Category.SCHEDULING })
+ consumerOnly = true, category = { Category.CORE, Category.SCHEDULING }, headersClass = SchedulerConstants.class)
public class SchedulerEndpoint extends ScheduledPollEndpoint {
@UriPath