Monday 24 February 2014

Textual description of firstImageUrl

How To Write Cron Job In Mule : Example

Creating Cron Job or a Scheduler in Mule is very easy by using Mule's Quartz Transport . Here's is simple mule flow which triggered every five minutes .








You have to write cron expression in quartz endpoint of mule like this :
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd 
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
   <spring:beans>
    <spring:bean class="TestBean" name="test" id="test">
    </spring:bean>
    </spring:beans>
 <flow name="generateStockTicks" doc:name="generateStockTicks">
        <quartz:inbound-endpoint jobName="eventTimer" doc:name="Quartz" 
        cronExpression="0 0/5 * * * ?">
            <quartz:event-generator-job>
                <quartz:payload>tick-tock</quartz:payload>
            </quartz:event-generator-job>
        </quartz:inbound-endpoint>
        
             <component doc:name="Java">
            <spring-object bean="test"/>
        </component>
        <set-payload value="123456" doc:name="Set Payload"/>
        <logger message="Cron Job Running #[message.payload]" doc:name="Logger" level="INFO"/>
       
        
    </flow>
    
    
</mule>

Download the complete source code of mule cron job example .


Post Comments and Suggestions !!