---
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    funktion.fabric8.io/kind: Connector
  name: quartz
data:
  deployment.yml: |
    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      labels:
        funktion.fabric8.io/kind: Subscription
        connector: quartz
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            funktion.fabric8.io/kind: Subscription
            connector: quartz
        spec:
          containers:
          - image: funktion/connector-quartz:${project.version}
            name: connector
  schema.yml: |
    ---
    component:
      kind: component
      scheme: quartz
      syntax: quartz:groupName/timerName
      title: Quartz
      description: Provides a scheduled delivery of messages using the Quartz 1.x scheduler.
      label: scheduling
      deprecated: true
      async: false
      consumerOnly: true
      javaType: org.apache.camel.component.quartz.QuartzComponent
      groupId: org.apache.camel
      artifactId: camel-quartz
      version: 2.18.3
    componentProperties:
      factory:
        kind: property
        type: object
        javaType: org.quartz.SchedulerFactory
        deprecated: false
        secret: false
        description: To use the custom SchedulerFactory which is used to create the Scheduler.
        order: 0
      scheduler:
        kind: property
        type: object
        javaType: org.quartz.Scheduler
        deprecated: false
        secret: false
        description: To use the custom configured Quartz scheduler instead of creating a new Scheduler.
        order: 1
      properties:
        kind: property
        type: object
        javaType: java.util.Properties
        deprecated: false
        secret: false
        description: Properties to configure the Quartz scheduler.
        order: 2
      propertiesFile:
        kind: property
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: File name of the properties to load from the classpath
        order: 3
      startDelayedSeconds:
        kind: property
        type: integer
        javaType: int
        deprecated: false
        secret: false
        description: Seconds to wait before starting the quartz scheduler.
        order: 4
      autoStartScheduler:
        kind: property
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        description: Whether or not the scheduler should be auto started. This options is default true
        order: 5
      enableJmx:
        kind: property
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        description: Whether to enable Quartz JMX which allows to manage the Quartz scheduler from JMX. This options is default true
        order: 6
    properties:
      groupName:
        kind: path
        group: consumer
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        defaultValue: Camel
        description: The quartz group name to use. The combination of group name and timer name should be unique.
        order: 0
      timerName:
        kind: path
        group: consumer
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: The quartz timer name to use. The combination of group name and timer name should be unique.
        order: 1
      bridgeErrorHandler:
        kind: parameter
        group: consumer
        label: consumer
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: 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 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/ERROR level and ignored.
        order: 2
      cron:
        kind: parameter
        group: consumer
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Specifies a cron expression to define when to trigger.
        order: 3
      deleteJob:
        kind: parameter
        group: consumer
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: true
        description: If set to true then the trigger automatically delete when route stop. Else if set to false it will remain in scheduler. When set to false it will also mean user may reuse pre-configured trigger with camel Uri. Just ensure the names match. Notice you cannot have both deleteJob and pauseJob set to true.
        order: 4
      fireNow:
        kind: parameter
        group: consumer
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Whether to fire the scheduler asap when its started using the simple trigger (this option does not support cron)
        order: 5
      jobParameters:
        kind: parameter
        group: consumer
        type: object
        javaType: java.util.Map<java.lang.String,java.lang.Object>
        prefix: job.
        multiValue: true
        deprecated: false
        secret: false
        description: To configure additional options on the job.
        order: 6
      pauseJob:
        kind: parameter
        group: consumer
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: If set to true then the trigger automatically pauses when route stop. Else if set to false it will remain in scheduler. When set to false it will also mean user may reuse pre-configured trigger with camel Uri. Just ensure the names match. Notice you cannot have both deleteJob and pauseJob set to true.
        order: 7
      startDelayedSeconds:
        kind: parameter
        group: consumer
        type: integer
        javaType: int
        deprecated: false
        secret: false
        description: Seconds to wait before starting the quartz scheduler.
        order: 8
      stateful:
        kind: parameter
        group: consumer
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Uses a Quartz StatefulJob instead of the default job.
        order: 9
      triggerParameters:
        kind: parameter
        group: consumer
        type: object
        javaType: java.util.Map<java.lang.String,java.lang.Object>
        prefix: trigger.
        multiValue: true
        deprecated: false
        secret: false
        description: To configure additional options on the trigger.
        order: 10
      usingFixedCamelContextName:
        kind: parameter
        group: consumer
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: If it is true JobDataMap uses the CamelContext name directly to reference the CamelContext if it is false JobDataMap uses use the CamelContext management name which could be changed during the deploy time.
        order: 11
      exceptionHandler:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: object
        javaType: org.apache.camel.spi.ExceptionHandler
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
        order: 12
      exchangePattern:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: string
        javaType: org.apache.camel.ExchangePattern
        enum:
        - InOnly
        - RobustInOnly
        - InOut
        - InOptionalOut
        - OutOnly
        - RobustOutOnly
        - OutIn
        - OutOptionalIn
        deprecated: false
        secret: false
        description: Sets the exchange pattern when the consumer creates an exchange.
        order: 13
      synchronous:
        kind: parameter
        group: advanced
        label: advanced
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
        order: 14
  documentation.adoc: |+
    [[Quartz-QuartzComponent]]
    Quartz Component
    ~~~~~~~~~~~~~~~~

    The *quartz:* component provides a scheduled delivery of messages using
    the http://www.quartz-scheduler.org/[Quartz Scheduler 1.x].  +
     Each endpoint represents a different timer (in Quartz terms, a Trigger
    and JobDetail).

    TIP: If you are using Quartz 2.x then from Camel 2.12 onwards there is a
    link:quartz2.html[Quartz2] component you should use

    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-quartz</artifactId>
        <version>x.x.x</version>
        <!-- use the same version as your Camel core version -->
    </dependency>
    ------------------------------------------------------------

    [[Quartz-URIformat]]
    URI format
    ^^^^^^^^^^

    [source,java]
    --------------------------------------------
    quartz://timerName?options
    quartz://groupName/timerName?options
    quartz://groupName/timerName?cron=expression
    quartz://timerName?cron=expression
    --------------------------------------------

    The component uses either a `CronTrigger` or a `SimpleTrigger`. If no
    cron expression is provided, the component uses a simple trigger. If no
    `groupName` is provided, the quartz component uses the `Camel` group
    name.

    You can append query options to the URI in the following format,
    `?option=value&option=value&...`

    [[Quartz-Options]]
    Options
    ^^^^^^^



    // component options: START
    The Quartz component supports 7 options which are listed below.



    {% raw %}
    [width="100%",cols="2,1m,7",options="header"]
    |=======================================================================
    | Name | Java Type | Description
    | factory | SchedulerFactory | To use the custom SchedulerFactory which is used to create the Scheduler.
    | scheduler | Scheduler | To use the custom configured Quartz scheduler instead of creating a new Scheduler.
    | properties | Properties | Properties to configure the Quartz scheduler.
    | propertiesFile | String | File name of the properties to load from the classpath
    | startDelayedSeconds | int | Seconds to wait before starting the quartz scheduler.
    | autoStartScheduler | boolean | Whether or not the scheduler should be auto started. This options is default true
    | enableJmx | boolean | Whether to enable Quartz JMX which allows to manage the Quartz scheduler from JMX. This options is default true
    |=======================================================================
    {% endraw %}
    // component options: END




    // endpoint options: START
    The Quartz component supports 15 endpoint options which are listed below:

    {% raw %}
    [width="100%",cols="2,1,1m,1m,5",options="header"]
    |=======================================================================
    | Name | Group | Default | Java Type | Description
    | groupName | consumer | Camel | String | The quartz group name to use. The combination of group name and timer name should be unique.
    | timerName | consumer |  | String | *Required* The quartz timer name to use. The combination of group name and timer name should be unique.
    | bridgeErrorHandler | consumer | false | boolean | 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/ERROR level and ignored.
    | cron | consumer |  | String | Specifies a cron expression to define when to trigger.
    | deleteJob | consumer | true | boolean | If set to true then the trigger automatically delete when route stop. Else if set to false it will remain in scheduler. When set to false it will also mean user may reuse pre-configured trigger with camel Uri. Just ensure the names match. Notice you cannot have both deleteJob and pauseJob set to true.
    | fireNow | consumer | false | boolean | Whether to fire the scheduler asap when its started using the simple trigger (this option does not support cron)
    | jobParameters | consumer |  | Map | To configure additional options on the job.
    | pauseJob | consumer | false | boolean | If set to true then the trigger automatically pauses when route stop. Else if set to false it will remain in scheduler. When set to false it will also mean user may reuse pre-configured trigger with camel Uri. Just ensure the names match. Notice you cannot have both deleteJob and pauseJob set to true.
    | startDelayedSeconds | consumer |  | int | Seconds to wait before starting the quartz scheduler.
    | stateful | consumer | false | boolean | Uses a Quartz StatefulJob instead of the default job.
    | triggerParameters | consumer |  | Map | To configure additional options on the trigger.
    | usingFixedCamelContextName | consumer | false | boolean | If it is true JobDataMap uses the CamelContext name directly to reference the CamelContext if it is false JobDataMap uses use the CamelContext management name which could be changed during the deploy time.
    | exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
    | exchangePattern | consumer (advanced) |  | ExchangePattern | Sets the exchange pattern when the consumer creates an exchange.
    | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
    |=======================================================================
    {% endraw %}
    // endpoint options: END


    When using a
    http://quartz-scheduler.org/api/2.0.0/org/quartz/StatefulJob.html[StatefulJob],
    the
    http://quartz-scheduler.org/api/2.0.0/org/quartz/JobDataMap.html[JobDataMap]
    is re-persisted after every execution of the job, thus preserving state
    for the next execution.


    INFO: *Running in OSGi and having multiple bundles with quartz
    routes*
    If you run in OSGi such as Apache ServiceMix, or Apache Karaf, and have
    multiple bundles with Camel routes that start from
    link:quartz.html[Quartz] endpoints, then make sure if you assign +
     an `id` to the <camelContext> that this id is unique, as this is
    required by the `QuartzScheduler` in the OSGi container. If you do not
    set any `id` on <camelContext> then +
     a unique id is auto assigned, and there is no problem.

    [[Quartz-Configuringquartz.propertiesfile]]
    Configuring quartz.properties file
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    By default Quartz will look for a `quartz.properties` file in the
    `org/quartz` directory of the classpath. If you are using WAR
    deployments this means just drop the quartz.properties in
    `WEB-INF/classes/org/quartz`.

    However the Camel link:quartz.html[Quartz] component also allows you to
    configure properties:

    [width="100%",cols="10%,10%,10%,70%",options="header",]
    |=======================================================================
    |Parameter |Default |Type |Description

    |`properties` |`null` |`Properties` |*Camel 2.4*: You can configure a `java.util.Properties` instance.

    |`propertiesFile` |`null` |`String` |*Camel 2.4*: File name of the properties to load from the classpath
    |=======================================================================

    To do this you can configure this in Spring XML as follows

    [source,xml]
    -------------------------------------------------------------------------------
    <bean id="quartz" class="org.apache.camel.component.quartz.QuartzComponent">
        <property name="propertiesFile" value="com/mycompany/myquartz.properties"/>
    </bean>
    -------------------------------------------------------------------------------

    [[Quartz-EnablingQuartzschedulerinJMX]]
    Enabling Quartz scheduler in JMX
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    You need to configure the quartz scheduler properties to enable JMX. +
     That is typically setting the option
    `"org.quartz.scheduler.jmx.export"` to a `true` value in the
    configuration file.

    From Camel 2.13 onwards Camel will automatic set this option to true,
    unless explicit disabled.

    [[Quartz-StartingtheQuartzscheduler]]
    Starting the Quartz scheduler
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    This is an example:

    [source,xml]
    ----------------------------------------------------------------------------
    <bean id="quartz" class="org.apache.camel.component.quartz.QuartzComponent">
        <property name="startDelayedSeconds" value="5"/>
    </bean>
    ----------------------------------------------------------------------------

    [[Quartz-Clustering]]
    Clustering
    ^^^^^^^^^^

    *Available as of Camel 2.4*

    If you use Quartz in clustered mode, e.g. the `JobStore` is clustered.
    Then from Camel 2.4 onwards the link:quartz.html[Quartz] component will
    *not* pause/remove triggers when a node is being stopped/shutdown. This
    allows the trigger to keep running on the other nodes in the cluster.

    *Note*: When running in clustered node no checking is done to ensure
    unique job name/group for endpoints.

    [[Quartz-MessageHeaders]]
    Message Headers
    ^^^^^^^^^^^^^^^

    Camel adds the getters from the Quartz Execution Context as header
    values. The following headers are added: +
     `calendar`, `fireTime`, `jobDetail`, `jobInstance`, `jobRuntTime`,
    `mergedJobDataMap`, `nextFireTime`, `previousFireTime`, `refireCount`,
    `result`, `scheduledFireTime`, `scheduler`, `trigger`, `triggerName`,
    `triggerGroup`.

    The `fireTime` header contains the `java.util.Date` of when the exchange
    was fired.

    [[Quartz-UsingCronTriggers]]
    Using Cron Triggers
    ^^^^^^^^^^^^^^^^^^^

    Quartz supports
    http://www.quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/crontrigger[Cron-like
    expressions] for specifying timers in a handy format. You can use these
    expressions in the `cron` URI parameter; though to preserve valid URI
    encoding we allow + to be used instead of spaces. Quartz provides a
    http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html[little
    tutorial] on how to use cron expressions.

    For example, the following will fire a message every five minutes
    starting at 12pm (noon) to 6pm on weekdays:

    [source,java]
    -----------------------------------------------------------------------------------------------
    from("quartz://myGroup/myTimerName?cron=0+0/5+12-18+?+*+MON-FRI").to("activemq:Totally.Rocks");
    -----------------------------------------------------------------------------------------------

    which is equivalent to using the cron expression

    [source,java]
    -----------------------
    0 0/5 12-18 ? * MON-FRI
    -----------------------

    The following table shows the URI character encodings we use to preserve
    valid URI syntax:

    [width="100%",cols="50%,50%",options="header",]
    |=======================================================================
    |URI Character |Cron character

    |`+` | _Space_
    |=======================================================================

    [[Quartz-Specifyingtimezone]]
    Specifying time zone
    ^^^^^^^^^^^^^^^^^^^^

    *Available as of Camel 2.8.1* +
     The Quartz Scheduler allows you to configure time zone per trigger. For
    example to use a timezone of your country, then you can do as follows:

    [source,java]
    -------------------------------------------------------------------------------------------
    quartz://groupName/timerName?cron=0+0/5+12-18+?+*+MON-FRI&trigger.timeZone=Europe/Stockholm
    -------------------------------------------------------------------------------------------

    The timeZone value is the values accepted by `java.util.TimeZone`.

    In Camel 2.8.0 or older versions you would have to provide your custom
    `String` to `java.util.TimeZone` link:type-converter.html[Type
    Converter] to be able configure this from the endpoint uri. +
     From Camel 2.8.1 onwards we have included such a
    link:type-converter.html[Type Converter] in the camel-core.

    [[Quartz-SeeAlso]]
    See Also
    ^^^^^^^^

    * link:configuring-camel.html[Configuring Camel]
    * link:component.html[Component]
    * link:endpoint.html[Endpoint]
    * link:getting-started.html[Getting Started]

    * link:quartz2.html[Quartz2]
    * link:timer.html[Timer]

