I've just checked in the code for the simplified Quartz-based
scheduling of jobs.
Here is how it works:
You define a class that implements org.apache.synapse.startup.Job. You
most likely need to also implement ManagedLifeCycle to get hold of the
SynapseEnvironment at init() time.
Your class can also implement setX(String val) or setY(OMElement val2)
and these will be injected before execute(); is called.
You then define when and how often to call this class, along with any
injectable properties.
Here is a sample synapse.xml fragment:
<startup>
<job class="MessageInjector">
<simpletrigger count="10" interval="5000"/>
<property name="message">
<test xmlns="urn:paul"/>
</property>
<property name="to" value="urn:test"/>
</job>
</startup>
To make life a little easier I figured we might create some default
built-in Jobs. I've created a package org.apache.synapse.startup.jobs.
There is one job there already - MessageInjector. It allows you to
specify a static XML and To address and it injects a message there.
To make life a teensy bit easier, you don't need to specify the full
class name for any job in that package. If there is no package set
then I concatenate that package, so specifying class="MessageInjector"
is the same as specifying
"org.apache.synapse.startup.jobs.MessageInjector
Here is core of the code for MessageInjector:
public void execute() {
MessageContext mc = synapseEnvironment.createMessageContext();
mc.setTo(new EndpointReference(to));
PayloadHelper.setXMLPayload(mc, message.cloneOMElement());
synapseEnvironment.injectMessage(mc);
}
You can read the full code here:
http://tinyurl.com/2v465m
Personally I think this is a nice feature (yeah I know I added it :-))
One last thing - the build doesn't correctly add
commons-collection-3.1.jar to the Synapse lib directory, so you need
to do that. Can someone (Ruwan!) please fix that?
Paul
--
Paul Fremantle
Co-Founder and VP of Technical Sales, WSO2
OASIS WS-RX TC Co-chair
blog: http://pzf.fremantle.org
[EMAIL PROTECTED]
"Oxygenating the Web Service Platform", www.wso2.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]