简体   繁体   中英

camel-quartz not working as expected in karaf

I am having an issue with apache camel quartz cron timers in karaf 4.0.3. It appears that when the quartz job executes, it is being executed multiple times. The following example blueprint is loaded as part of my "mass-orchestrator" app. The Hello World output prints out immediately multiple times. Instead, it should print out ONLY once every 2 minutes. Does anyone know what is happening here and how to correct it?

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
  xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0"
  xsi:schemaLocation="
    http://www.osgi.org/xmlns/blueprint/v1.0.0 
    http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd

    http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
    http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd

    http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0
    http://aries.apache.org/schemas/blueprint-ext/blueprint-ext-1.1.xsd">

  <camelContext xmlns="http://camel.apache.org/schema/blueprint"
    id="simple">
    <route>
        <from uri="quartz:myTimerName?cron=*+0/2+*+*+*+?" />
        <setBody>
            <simple>Hello World</simple>
        </setBody>
        <to uri="stream:out" />
    </route>
  </camelContext>
</blueprint>

I then launch Karaf clean and install the latest camel (but I was able to reproduce in many versions of camel going back to 2.12).

       __ __                  ____
   / //_/____ __________ _/ __/
  / ,<  / __ `/ ___/ __ `/ /_
 / /| |/ /_/ / /  / /_/ / __/
/_/ |_|\__,_/_/   \__,_/_/

Apache Karaf (4.0.3)

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.

karaf@root()> feature:repo-add camel
Adding feature url mvn:org.apache.camel.karaf/apache-camel/LATEST/xml/features
karaf@root()> feature:install camel-blueprint
karaf@root()> feature:install camel-quartz
karaf@root()> feature:install camel-stream
karaf@root()> install mvn:com.cerner.cts.oss/mass-orchestrator/1.0.0-SNAPSHOT
Bundle ID: 66
karaf@root()> list
START LEVEL 100 , List Threshold: 50
ID | State     | Lvl | Version         | Name
----------------------------------------------------------------------------------
52 | Active    |  80 | 2.17.0.SNAPSHOT | camel-blueprint
53 | Active    |  80 | 2.17.0.SNAPSHOT | camel-catalog
54 | Active    |  80 | 2.17.0.SNAPSHOT | camel-commands-core
55 | Active    |  80 | 2.17.0.SNAPSHOT | camel-core
56 | Active    |  80 | 2.17.0.SNAPSHOT | camel-karaf-commands
57 | Active    |  80 | 2.2.6.1         | Apache ServiceMix :: Bundles :: jaxb-impl
58 | Active    |  80 | 3.1.4           | Stax2 API
59 | Active    |  80 | 4.4.1           | Woodstox XML-processor
60 | Active    |  80 | 2.17.0.SNAPSHOT | camel-quartz
61 | Active    |  80 | 1.4             | Commons DBCP
62 | Active    |  80 | 1.6.0           | Commons Pool
63 | Active    |  80 | 1.1.1           | geronimo-jta_1.1_spec
64 | Active    |  80 | 1.8.6.1         | Apache ServiceMix :: Bundles ::     quartz
65 | Active    |  80 | 2.17.0.SNAPSHOT | camel-stream
66 | Installed |  80 | 1.0.0.SNAPSHOT  | mass-orchestrator
karaf@root()> start 66
karaf@root()> Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
<snip>

karaf@root()>

The cron should be

0+0/2+*+*+*+?

To run only once every 2nd minute. If you use * it means that it runs every seconds in intervals of every 2nd minute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM