You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by Paul Fremantle <pz...@gmail.com> on 2007/08/01 17:31:56 UTC
Simplifying the use of Quartz
I've written a Quartz plugin for Synapse, which allows Quartz Jobs to
be run by Quartz in the context of Synapse. In particular, they have
access to the SynapseEnvironment, so that they can inject messages
into Synapse.
However, the Quartz model isn't quite as simple as the Synapse model
(in my opinion).
Basically Quartz Jobs implement a method
public void execute(JobExecutionContext arg0) throws JobExecutionException
And from the JobExecutionContext they get any properties they need.
The jobs can be specified either programmatically or using Quartz XML
syntax, but the Quartz syntax is a bit "heavy". For example in synapse
we set a property this way:
<property name="address" value="urn:gmond"/>
In Quartz its like this:
<quartz:entry>
<quartz:key>port</quartz:key>
<quartz:value>8649</quartz:value>
</quartz:entry>
Since I've already coded support for the Quartz model, I suggest we
keep that as one approach, but I think we could make life much simpler
for users:
Here is a proposed XML:
<job class="org.my.synapse.job">
<property name="stringProp" value="String"/>
<property name="xmlProp">
<somexml>config</somexml>
</property>
<simpletrigger count="-1" interval="1000"/>
<crontrigger expression="0 * 1 * * ?"/>
</job>
We will use Quartz under the covers to call our own job handling code,
which can use injection to inject the properties into the Job instance
and then call execute(); on the Job.
This basically makes it simpler to write AND configure a job.
Paul
--
Paul Fremantle
Co-Founder and VP of Technical Sales, WSO2
OASIS WS-RX TC Co-chair
blog: http://pzf.fremantle.org
paul@wso2.com
"Oxygenating the Web Service Platform", www.wso2.com
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org
Re: Simplifying the use of Quartz
Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
+1 for keeping cron syntax and having a set of attrs.
Sanjiva.
Paul Fremantle wrote:
> Roland
>
> I *will* fix this up according to your ideas. I fully agree. But for a
> first release it was definitely easier to push down to the existing
> Quartz model.
>
> Paul
>
> On 8/7/07, Roland Weber <os...@dubioso.net> wrote:
>>> "That string", I believe, is based on standard unix crontab format,
>>> which makes it very easy for people used to that format to cut+paste,
>>> or to simply type.
>> ...and requires everyone else to look up a manpage ;-)
>> It's as standard as it gets. Quote from the manpage [1]:
>>
>>> When specifying day of week, both day 0 and day 7 will be
>>> considered Sunday. BSD and ATT seem to disagree about this.
>> Plus some other convenience extension of which you can never
>> tell which cron implementation supports them and which doesn't.
>>
>> cheers,
>> Roland
>>
>> [1] http://gentoo-wiki.com/MAN_crontab_5
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: synapse-dev-help@ws.apache.org
>>
>>
>
>
--
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org
Re: Simplifying the use of Quartz
Posted by Paul Fremantle <pz...@gmail.com>.
Roland
I *will* fix this up according to your ideas. I fully agree. But for a
first release it was definitely easier to push down to the existing
Quartz model.
Paul
On 8/7/07, Roland Weber <os...@dubioso.net> wrote:
> > "That string", I believe, is based on standard unix crontab format,
> > which makes it very easy for people used to that format to cut+paste,
> > or to simply type.
>
> ...and requires everyone else to look up a manpage ;-)
> It's as standard as it gets. Quote from the manpage [1]:
>
> > When specifying day of week, both day 0 and day 7 will be
> > considered Sunday. BSD and ATT seem to disagree about this.
>
> Plus some other convenience extension of which you can never
> tell which cron implementation supports them and which doesn't.
>
> cheers,
> Roland
>
> [1] http://gentoo-wiki.com/MAN_crontab_5
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-dev-help@ws.apache.org
>
>
--
Paul Fremantle
Co-Founder and VP of Technical Sales, WSO2
OASIS WS-RX TC Co-chair
blog: http://pzf.fremantle.org
paul@wso2.com
"Oxygenating the Web Service Platform", www.wso2.com
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org
Re: Simplifying the use of Quartz
Posted by Roland Weber <os...@dubioso.net>.
> "That string", I believe, is based on standard unix crontab format,
> which makes it very easy for people used to that format to cut+paste,
> or to simply type.
...and requires everyone else to look up a manpage ;-)
It's as standard as it gets. Quote from the manpage [1]:
> When specifying day of week, both day 0 and day 7 will be
> considered Sunday. BSD and ATT seem to disagree about this.
Plus some other convenience extension of which you can never
tell which cron implementation supports them and which doesn't.
cheers,
Roland
[1] http://gentoo-wiki.com/MAN_crontab_5
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org
Re: Simplifying the use of Quartz
Posted by Paul Fremantle <pz...@gmail.com>.
I've been looking at the cron scheduling here:
http://quartz.sourceforge.net/javadoc/org/quartz/CronTrigger.html
The model is a little complex, and its not clear to me what the
defaults should be. So I'll check in a simple version that uses the
cron expression and take a look at splitting it into attributes later.
Paul
<job class="org.my.synapse.job">
<property name="stringProp" value="String"/>
<property name="xmlProp">
<somexml>config</somexml>
</property>
<simpletrigger forever="true" count="10" interval="1000"/> <!--
forever or count not both -->
<crontrigger expression="0 * 1 * * ?" />
</job>
Paul
On 8/7/07, Ruwan Linton <ru...@gmail.com> wrote:
>
>
> On 8/7/07, Glen Daniels <gl...@thoughtcraft.com> wrote:
> > Paul Fremantle wrote:
> > > Thanks for the input. i was being lazy - this is the format that the
> > > existing Quartz code uses and it parses that string for you. However,
> > > I agree - from an ease of use aspect, that isn't helping.
> >
> > "That string", I believe, is based on standard unix crontab format,
> > which makes it very easy for people used to that format to cut+paste, or
> > to simply type. The "*" character in crontab format means "all" or, in
> > other words, the same thing as omitting an attribute in Roland's
> > suggested format.
> >
> > > So I will use your idea. Now I think about it, I might also change the
> > > count="-1" to be a forever="true" | count="1 or more".
> >
> > Maybe support both? So expression="crontab-expr" works, as does
> > hour="4"/minute="20"....
>
>
> +1 for supporting both. That way we are keeping the ease of use for the
> people who are familiar with UNIX cron without typing 5 different attributes
> to accomplish a simple task in the cron.
>
> Thanks,
> Ruwan.
>
> > --Glen
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> synapse-dev-unsubscribe@ws.apache.org
> > For additional commands, e-mail: synapse-dev-help@ws.apache.org
> >
> >
>
>
>
> --
> Ruwan Linton
> http://www.wso2.org - "Oxygenating the Web Services Platform"
--
Paul Fremantle
Co-Founder and VP of Technical Sales, WSO2
OASIS WS-RX TC Co-chair
blog: http://pzf.fremantle.org
paul@wso2.com
"Oxygenating the Web Service Platform", www.wso2.com
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org
Re: Simplifying the use of Quartz
Posted by Ruwan Linton <ru...@gmail.com>.
On 8/7/07, Glen Daniels <gl...@thoughtcraft.com> wrote:
>
> Paul Fremantle wrote:
> > Thanks for the input. i was being lazy - this is the format that the
> > existing Quartz code uses and it parses that string for you. However,
> > I agree - from an ease of use aspect, that isn't helping.
>
> "That string", I believe, is based on standard unix crontab format,
> which makes it very easy for people used to that format to cut+paste, or
> to simply type. The "*" character in crontab format means "all" or, in
> other words, the same thing as omitting an attribute in Roland's
> suggested format.
>
> > So I will use your idea. Now I think about it, I might also change the
> > count="-1" to be a forever="true" | count="1 or more".
>
> Maybe support both? So expression="crontab-expr" works, as does
> hour="4"/minute="20"....
+1 for supporting both. That way we are keeping the ease of use for the
people who are familiar with UNIX cron without typing 5 different attributes
to accomplish a simple task in the cron.
Thanks,
Ruwan.
--Glen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-dev-help@ws.apache.org
>
>
--
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"
Re: Simplifying the use of Quartz
Posted by Glen Daniels <gl...@thoughtcraft.com>.
Paul Fremantle wrote:
> Thanks for the input. i was being lazy - this is the format that the
> existing Quartz code uses and it parses that string for you. However,
> I agree - from an ease of use aspect, that isn't helping.
"That string", I believe, is based on standard unix crontab format,
which makes it very easy for people used to that format to cut+paste, or
to simply type. The "*" character in crontab format means "all" or, in
other words, the same thing as omitting an attribute in Roland's
suggested format.
> So I will use your idea. Now I think about it, I might also change the
> count="-1" to be a forever="true" | count="1 or more".
Maybe support both? So expression="crontab-expr" works, as does
hour="4"/minute="20"....
--Glen
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org
Re: Simplifying the use of Quartz
Posted by Paul Fremantle <pz...@gmail.com>.
Roland
Thanks for the input. i was being lazy - this is the format that the
existing Quartz code uses and it parses that string for you. However,
I agree - from an ease of use aspect, that isn't helping.
So I will use your idea. Now I think about it, I might also change the
count="-1" to be a forever="true" | count="1 or more".
Paul
On 8/6/07, Roland Weber <os...@dubioso.net> wrote:
> > Here is a proposed XML:
> >
> > <job class="org.my.synapse.job">
> > <property name="stringProp" value="String"/>
> > <property name="xmlProp">
> > <somexml>config</somexml>
> > </property>
> > <simpletrigger count="-1" interval="1000"/>
> > <crontrigger expression="0 * 1 * * ?"/>
> > </job>
>
> I did some research on XML design guidelines for
> a presentation last year. While the element vs.
> attribute decisions are somehow tricky, there
> is one rule for which I found no contradiction:
>
> > Don't put structured content into an attribute.
>
> Based on that rule, the <crontrigger expression="..."/>
> looks pretty bad. So if you prefer the attribute
> approach to keep handcrafting of the XML files
> simple, I would suggest to split the expression
> into separate attributes:
>
> <crontrigger minute="0" hour="*" dayofweek="1"
> dayofmonth="*" month="?" />
>
> This would also allow users to specify only
> the relevant attributes, like:
>
> <crontrigger hour="*" dayofweek="1" />
>
>
> For what it's worth, the best rule on element vs.
> attribute I found was:
>
> > Put data into elements, metadata into attributes.
>
> But if the rest of your XML schema favors attributes
> over elements, it's better to keep it consistent.
>
> cheers,
> Roland
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-dev-help@ws.apache.org
>
>
--
Paul Fremantle
Co-Founder and VP of Technical Sales, WSO2
OASIS WS-RX TC Co-chair
blog: http://pzf.fremantle.org
paul@wso2.com
"Oxygenating the Web Service Platform", www.wso2.com
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org
Re: Simplifying the use of Quartz
Posted by Roland Weber <os...@dubioso.net>.
> Here is a proposed XML:
>
> <job class="org.my.synapse.job">
> <property name="stringProp" value="String"/>
> <property name="xmlProp">
> <somexml>config</somexml>
> </property>
> <simpletrigger count="-1" interval="1000"/>
> <crontrigger expression="0 * 1 * * ?"/>
> </job>
I did some research on XML design guidelines for
a presentation last year. While the element vs.
attribute decisions are somehow tricky, there
is one rule for which I found no contradiction:
> Don't put structured content into an attribute.
Based on that rule, the <crontrigger expression="..."/>
looks pretty bad. So if you prefer the attribute
approach to keep handcrafting of the XML files
simple, I would suggest to split the expression
into separate attributes:
<crontrigger minute="0" hour="*" dayofweek="1"
dayofmonth="*" month="?" />
This would also allow users to specify only
the relevant attributes, like:
<crontrigger hour="*" dayofweek="1" />
For what it's worth, the best rule on element vs.
attribute I found was:
> Put data into elements, metadata into attributes.
But if the rest of your XML schema favors attributes
over elements, it's better to keep it consistent.
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org
Re: Simplifying the use of Quartz
Posted by "Asankha C. Perera" <as...@wso2.com>.
+1
asankha
Paul Fremantle wrote:
> I've written a Quartz plugin for Synapse, which allows Quartz Jobs to
> be run by Quartz in the context of Synapse. In particular, they have
> access to the SynapseEnvironment, so that they can inject messages
> into Synapse.
>
> However, the Quartz model isn't quite as simple as the Synapse model
> (in my opinion).
> Basically Quartz Jobs implement a method
> public void execute(JobExecutionContext arg0) throws JobExecutionException
>
> And from the JobExecutionContext they get any properties they need.
>
> The jobs can be specified either programmatically or using Quartz XML
> syntax, but the Quartz syntax is a bit "heavy". For example in synapse
> we set a property this way:
>
> <property name="address" value="urn:gmond"/>
>
> In Quartz its like this:
> <quartz:entry>
> <quartz:key>port</quartz:key>
> <quartz:value>8649</quartz:value>
> </quartz:entry>
>
> Since I've already coded support for the Quartz model, I suggest we
> keep that as one approach, but I think we could make life much simpler
> for users:
>
> Here is a proposed XML:
>
> <job class="org.my.synapse.job">
> <property name="stringProp" value="String"/>
> <property name="xmlProp">
> <somexml>config</somexml>
> </property>
> <simpletrigger count="-1" interval="1000"/>
> <crontrigger expression="0 * 1 * * ?"/>
> </job>
>
> We will use Quartz under the covers to call our own job handling code,
> which can use injection to inject the properties into the Job instance
> and then call execute(); on the Job.
>
> This basically makes it simpler to write AND configure a job.
>
> Paul
>
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org