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 2020/01/13 11:30:46 UTC

[camel] 02/08: CAMEL-14385: update docs and manifests for camel-cron component

This is an automated email from the ASF dual-hosted git repository.

nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8a067cafe51a4d0035775b92c4152e2339b48501
Author: Nicola Ferraro <ni...@gmail.com>
AuthorDate: Fri Jan 10 13:06:51 2020 +0100

    CAMEL-14385: update docs and manifests for camel-cron component
---
 apache-camel/pom.xml                               |   5 +
 apache-camel/src/main/descriptors/common-bin.xml   |   1 +
 bom/camel-bom/pom.xml                              |   5 +
 docs/components/modules/ROOT/nav.adoc              |   1 +
 .../modules/ROOT/pages/cron-component.adoc         | 136 +++++++++++++++++++++
 docs/components/modules/ROOT/pages/index.adoc      |   4 +-
 .../modules/ROOT/pages/quartz-component.adoc       |  25 ++++
 7 files changed, 176 insertions(+), 1 deletion(-)

diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index ab2edaa..fa0d4e1 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -433,6 +433,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-cron</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-crypto</artifactId>
       <version>${project.version}</version>
     </dependency>
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index 3ef7e8b..533bdb5 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -107,6 +107,7 @@
         <include>org.apache.camel:camel-corda</include>
         <include>org.apache.camel:camel-couchbase</include>
         <include>org.apache.camel:camel-couchdb</include>
+        <include>org.apache.camel:camel-cron</include>
         <include>org.apache.camel:camel-crypto</include>
         <include>org.apache.camel:camel-crypto-cms</include>
         <include>org.apache.camel:camel-csv</include>
diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index f72ecdd..a639b8e 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -439,6 +439,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-cron</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-crypto</artifactId>
         <version>${project.version}</version>
       </dependency>
diff --git a/docs/components/modules/ROOT/nav.adoc b/docs/components/modules/ROOT/nav.adoc
index 0b5c531..c1493ff 100644
--- a/docs/components/modules/ROOT/nav.adoc
+++ b/docs/components/modules/ROOT/nav.adoc
@@ -76,6 +76,7 @@
 * xref:corda-component.adoc[Corda Component]
 * xref:couchbase-component.adoc[Couchbase Component]
 * xref:couchdb-component.adoc[CouchDB Component]
+* xref:cron-component.adoc[Cron Component]
 * xref:crypto-cms-component.adoc[Crypto CMS Component (deprecated)]
 * xref:crypto-component.adoc[Crypto (JCE) Component]
 * xref:crypto-dataformat.adoc[Crypto (Java Cryptographic Extension) DataFormat]
diff --git a/docs/components/modules/ROOT/pages/cron-component.adoc b/docs/components/modules/ROOT/pages/cron-component.adoc
new file mode 100644
index 0000000..3c5b6cd
--- /dev/null
+++ b/docs/components/modules/ROOT/pages/cron-component.adoc
@@ -0,0 +1,136 @@
+[[cron-component]]
+= Cron Component
+:page-source: components/camel-cron/src/main/docs/cron-component.adoc
+
+*Since Camel 3.1*
+
+// HEADER START
+*Only consumer is supported*
+// HEADER END
+
+The Cron component is a generic interface component that allows triggering events at specific time interval
+specified using the Unix cron syntax (e.g. `0/2 * * * * ?` to trigger an event every two seconds).
+
+Being an interface component, the Cron component does not contain a default implementation, instead it requires that the users plug
+the implementation of their choice.
+
+The following standard Camel components support the Cron endpoints:
+
+- Quartz
+
+The Cron component is also supported in **Camel K**, which can use the Kubernetes scheduler to trigger the routes when required by the cron expression.
+Camel K does not require additional libraries to be plugged when using cron expressions compatible with Kubernetes cron syntax.
+
+Maven users will need to add the following dependency to their `pom.xml`
+for this component:
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-cron</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+</dependency>
+------------------------------------------------------------
+
+Additional libraries may be needed in order to plug a specific implementation.
+
+== Options
+
+
+// component options: START
+The Cron component supports 4 options, which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *cronService* (advanced) | The id of the CamelCronService to use when multiple implementations are provided |  | String
+| *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
+| *lazyStartProducer* (producer) | 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 starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
+| *bridgeErrorHandler* (consumer) | 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 message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
+|===
+// component options: END
+
+
+
+
+
+// endpoint options: START
+The Cron endpoint is configured using URI syntax:
+
+----
+cron:name
+----
+
+with the following path and query parameters:
+
+=== Path Parameters (1 parameters):
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *name* | *Required* The name of the cron trigger |  | String
+|===
+
+
+=== Query Parameters (6 parameters):
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *bridgeErrorHandler* (consumer) | 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 message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
+| *schedule* (consumer) | *Required* A cron expression that will be used to generate events |  | String
+| *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
+| *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
+| *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
+| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
+|===
+// endpoint options: END
+
+== Usage
+
+The component can be used to trigger events at specified times, as in the following example:
+
+[source,java]
+---------------------------------------------------------
+from("cron:tab?schedule=0/1+*+*+*+*+?")
+.setBody().constant("event")
+.log("${body}");
+---------------------------------------------------------
+
+The schedule expression `0/3+10+*+*+*+?` can be also written as `0/3 10 * * * ?` and triggers an event every three seconds only in the tenth minute of each hour.
+
+Parts in the schedule expression means (in order):
+
+- Seconds (optional)
+- Minutes
+- Hours
+- Day of month
+- Month
+- Day of week
+- Year (optional)
+
+Schedule expressions can be made of 5 to 7 parts. When expressions are composed of 6 parts, the first items is the "seconds" part (and year is considered missing).
+
+Other valid examples of schedule expressions are:
+
+- `0/2 * * * ?` (5 parts, an event every two minutes)
+- `0 0/2 * * * MON-FRI 2030` (7 parts, an event every two minutes only in year 2030)
+
+Routes can also be written using the XML DSL.
+
+[source,xml]
+-------------
+<route>
+    <from uri="cron:tab?schedule=0/1+*+*+*+*+?"/>
+    <setBody>
+      <constant>event</constant>
+    </setBody>
+    <to uri="log:info"/>
+</route>
+-------------
diff --git a/docs/components/modules/ROOT/pages/index.adoc b/docs/components/modules/ROOT/pages/index.adoc
index 94275f8..a82b47d 100644
--- a/docs/components/modules/ROOT/pages/index.adoc
+++ b/docs/components/modules/ROOT/pages/index.adoc
@@ -6,7 +6,7 @@ The following Apache Camel artifacts are provided:
 == Components
 
 // components: START
-Number of Components: 307 in 245 JAR artifacts (1 deprecated)
+Number of Components: 308 in 246 JAR artifacts (1 deprecated)
 
 [width="100%",cols="4,1,5",options="header"]
 |===
@@ -134,6 +134,8 @@ Number of Components: 307 in 245 JAR artifacts (1 deprecated)
 
 | xref:couchdb-component.adoc[CouchDB] (camel-couchdb) | 2.11 | The couchdb component is used for integrate with CouchDB databases.
 
+| xref:cron-component.adoc[Cron] (camel-cron) | 3.1 | Camel Cron Component
+
 | xref:crypto-component.adoc[Crypto (JCE)] (camel-crypto) | 2.3 | The crypto component is used for signing and verifying exchanges using the Signature Service of the Java Cryptographic Extension (JCE).
 
 | xref:crypto-cms-component.adoc[Crypto CMS] (camel-crypto-cms) | 2.20 | *deprecated* The crypto cms component is used for encrypting data in CMS Enveloped Data format, decrypting CMS Enveloped Data, signing data in CMS Signed Data format, and verifying CMS Signed Data.
diff --git a/docs/components/modules/ROOT/pages/quartz-component.adoc b/docs/components/modules/ROOT/pages/quartz-component.adoc
index 9a27e7b..39dfd8d 100644
--- a/docs/components/modules/ROOT/pages/quartz-component.adoc
+++ b/docs/components/modules/ROOT/pages/quartz-component.adoc
@@ -468,3 +468,28 @@ use the following as well:
     from("file:inbox?scheduler=spring&scheduler.cron=0/2+*+*+*+*+?")
        .to("bean:process");
 ----
+
+== Cron Component Support
+
+The Quartz component can be used as implementation of the Camel Cron component.
+
+
+Maven users will need to add the following additional dependency to their `pom.xml`:
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-cron</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+</dependency>
+------------------------------------------------------------
+
+Users can then use the cron component instead of the quartz component, as in the following route:
+
+[source,java]
+----
+    from("cron://name?schedule=0+0/5+12-18+?+*+MON-FRI")
+    .to("activemq:Totally.Rocks");
+----