Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quartz / quartz2 plugin #786

Closed
davsclaus opened this issue Nov 28, 2013 · 35 comments
Closed

Quartz / quartz2 plugin #786

davsclaus opened this issue Nov 28, 2013 · 35 comments
Assignees
Milestone

Comments

@davsclaus
Copy link
Member

So we can manage the quartz scheduler from the web ui.

Would need to investigate what management api if all quartz offers. As quartz 1.x and 2.x API is so different, we may choose to support quartz2 at first, and then if possible quartz 1 later.

@jstrachan
Copy link
Contributor

Agreed. Incidentally I'd really like a Fabric Timer; which used ZK to determine who was going to execute a collection of timers. The partition stuff can do this kinda thing already really:

http://jboss-fuse.viewdocs.io/fuse/partition

I figure we could just define timers in property files; then let the Fabric Partition stuff make sure only 1 machine was running 1 set of timers at a time; then we just need a little bit of eye candy on the Partition stuff (to see which container is running what sets of timers) and to make it easy to edit the timer info?

@jonathanvila
Copy link

Is there a way I can contribute to this plugin ? I'm so interested in it.

@davsclaus
Copy link
Member Author

Yeah sure.

hawtio uses JMX API to integrate (though jolokia turns these JMX apis into REST). So the 1st step would to take a look at quartz and see what JMX APIs it offers.

Then another step would be able to build the source code and run hawtio on your computer. For that follow the steps on the how to build the code
http://hawt.io/building/index.html

You dont need to go full and do integration testing and whatnot. I dont do that. But the live reload is cool so you can do live changes.

Though if you have some problems with this, then its faster to get help on IRC where we hang out, and can help asap.

@jstrachan
Copy link
Contributor

On for sure, we love contributions! :)

Which bit did you fancy working on; the hawtio UI for working with quartz 2; or the back end for quartz which used the Fuse partition stuff? (Am guessing the former?)

I guess the first thing we'd need is a little example project to create a few quartz timers so there's something for the hawtio plugin to visualise/manage? e.g. we maybe need an example-quartz service module here:
https://github.com/hawtio/hawtio/tree/master/example-services

so folks can easily run quartz2 stuff and see the mbeans; then we can try work on a quartz plugin

@davsclaus
Copy link
Member Author

For a plugin as inspiration, then you may take a look at the tomcat plugin, which was the first plugin I improved/wrote AFAIR. Its a fairly simple plugin, and has a few sub tabs. And presents some data from tomcat. So maybe the first step is to be able to show information about the quartz scheduler, such as its version number, its state, and maybe other details.

And a table with all its jobs, and then later buttons to change these jobs etc.

@ghost ghost assigned davsclaus Dec 21, 2013
@jonathanvila
Copy link

I have this folder hierarchy , but the results are the same...... no JMX Quartz node ..... and no Quartz Hawtio menu.

selection_222

@davsclaus
Copy link
Member Author

And you have configured the quartz component in your camel blueprint.xml file to use your quartz.properties file? eg it needs to know its location on the classpath.

@jonathanvila
Copy link

No, I havent.

I expected that it searched the classpath, including my packages exported.

So, I have to explicitly configure the quartz component....... I'll try and come back.

@jonathanvila
Copy link

Oki.

This is what I have in my blueprint :

<bean id="quartz" class="org.apache.camel.component.quartz.QuartzComponent">
    <property name="propertiesFile" value="com/tesipro/conectores/expedia/quartz.properties"/>
</bean> 

This is what I have in my route :

from("quartz2://mitempo?trigger.repeatCount=-1&trigger.repeatInterval=2000").
            setBody(new SimpleExpression("mi mensaje ... ${threadName}...${date:now:yyyy-MM-dd HH:mm:ss.Z}")).
            to("stream:file?fileName=/home/jonathan/salida.txt")
             .to("activemq:queue:tesipro");

If I use quartz in my route then I receive this error :

Error occurred during starting Camel: CamelContext(simple) due Failed to create route route17: Route(route17)
[[From[quartz://mitempo?trigger.repeatCount=-1... because of Failed to resolve endpoint: quartz://mitempo?
trigger.repeatCount=-1&trigger.repeatInterval=2000 due to: Cannot auto create component: quartz

What am I doing wrong ?

@davsclaus
Copy link
Member Author

You need to use a recent JAR of camel-quartz / camel-quartz2 to have that working in OSGi blueprint, eg to configure the propertiesFile option.

See CAMEL-7140

@jonathanvila
Copy link

I'm using these bundles :

selection_223

@davsclaus
Copy link
Member Author

Yeah build 321 should have CAMEL-7140 included.

Ah spotted it. Make sure you use the same quartz component. In the blueprint its quartz 1.x.
And the in the java route its quartz2

Maybe use quartz2 as its the newer. 1.x is EOL.

Notice the bean id is quarz2 which is the component name Camel uses.

<bean id="quartz2" class="org.apache.camel.component.quartz2.QuartzComponent">
    <property name="propertiesFile" value="com/tesipro/conectores/expedia/quartz.properties"/>
</bean> 

@jonathanvila
Copy link

I've changed what you said.... but the result is the same :

Error occurred during starting Camel: CamelContext(simple) due Failed to create route route20: Route(route20)
[[From[quartz2://mitempo?trigger.repeatCount=-... because of Failed to resolve endpoint: quartz2://mitempo?
trigger.repeatCount=-1&trigger.repeatInterval=2000 due to: Cannot auto create component: quartz2

    <bean id="quartz2" class="org.apache.camel.component.quartz2.QuartzComponent">
        <property name="propertiesFile" value="com/tesipro/conectores/expedia/quartz.properties"/>
    </bean>        
    from("quartz2://mitempo?trigger.repeatCount=-1&trigger.repeatInterval=2000").
            setBody(new SimpleExpression("mi mensaje ... ${threadName}...${date:now:yyyy-MM-dd HH:mm:ss.Z}")).
            to("stream:file?fileName=/home/jonathan/salida.txt")
             .to("activemq:queue:tesipro");

@jonathanvila
Copy link

The stacktrace also contains :

Caused by: org.quartz.SchedulerException: Error loading Quartz properties file: 
com/tesipro/conectores/expedia/quartz.properties [See nested exception: java.io.FileNotFoundException: Cannot find 
resource: com/tesipro/conectores/expedia/quartz.properties in classpath for URI: 
com/tesipro/conectores/expedia/quartz.properties]
Caused by: java.io.FileNotFoundException: Cannot find resource: com/tesipro/conectores/expedia/quartz.properties 
in classpath for URI: com/tesipro/conectores/expedia/quartz.properties

It seems the problem is that the system does not find the properties file.....

@davsclaus
Copy link
Member Author

Do your bundle export the package: com/tesipro/conectores/expedia

@jonathanvila
Copy link

Yes, of course..... but just to test, I've copied the quartz.properties in every place I think would be in the classpath ( jre/lib/ext, instances/tesipro/deploy, instances/tesipro/etc, ...)

selection_224

@gashcrumb
Copy link
Member

Is it possible that the quartz component is just trying to open the properties file via new File(propertiesFile); and not look on the classpath? Maybe it's worth specifying an absolute path to the location of the file on your filesystem in the blueprint XML.

@jonathanvila
Copy link

I've tried that already, and not works either.

@jonathanvila
Copy link

Changing the method to obtain the file IT WORKS !!!

<bean id="quartz2" class="org.apache.camel.component.quartz2.QuartzComponent">
    <property name="propertiesFile" value="file:etc/quartz.properties"/>
</bean>      

selection_225

@abbasdgr8
Copy link

Hi,
I have hawtio setup and listening to my running Camel instance. I have two quartz2 endpoints running, but I can't see any Quartz schedulers in the tree on the left.
I have defined the endpoints in a properties file that I am consuming from my camel-config as follows :

<bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>file:src/main/resources/not_packaged_in_archive/dev/camel-dev.properties</value>
            </list>
        </property>
        <property name="ignoreResourceNotFound" value="true" />
    </bean>

...and my routes are running fine.

I read the conversation trail above. Is it necessary for me to declare my quartz properties in a different file and declare it as :

<bean id="quartz2" class="org.apache.camel.component.quartz2.QuartzComponent">
    <property name="propertiesFile" value="file:etc/quartz.properties"/>
</bean>

@davsclaus
Copy link
Member Author

If you do not use latest release of Camel, you need to enable JMX on quartz yourself. In the quartz properties file set

org.quartz.scheduler.jmx.export=true

@abbasdgr8
Copy link

Cheers! Worked when I did the following :

  1. Updated from Camel 2.12.2 to 2.12.3
  2. Declared quartz2 in my camel-config as :
<bean id="quartz2" class="org.apache.camel.component.quartz2.QuartzComponent">
        <property name="propertiesFile" value="file:src/main/resources/not_packaged_in_archive/dev/quartz.properties"/>
    </bean>
  1. Added the following properties to quartz.properties
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 3
org.quartz.scheduler.jmx.export=true

But, I'm using the Google Chrome hawtio extension. When I change the cron and click on "Update Trigger", it doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants