Writing cron job is very
easy in mule.You might get error like this in mule application start up :
Caused by: org.mule.api.lifecycle.LifecycleException: Failed to start inbound endpoint "endpoint.quartz.test.job"
at org.mule.endpoint.DefaultInboundEndpoint.start(DefaultInboundEndpoint.java:122)
at org.mule.construct.AbstractFlowConstruct.startIfStartable(AbstractFlowConstruct.java:317)
at org.mule.construct.AbstractPipeline.doStart(AbstractPipeline.java:302)
at org.mule.construct.AbstractFlowConstruct$2.onTransition(AbstractFlowConstruct.java:143)
at org.mule.construct.AbstractFlowConstruct$2.onTransition(AbstractFlowConstruct.java:139)
at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(AbstractLifecycleManager.java:141)
at org.mule.construct.FlowConstructLifecycleManager.fireStartPhase(FlowConstructLifecycleManager.java:95)
at org.mule.construct.AbstractFlowConstruct.start(AbstractFlowConstruct.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.mule.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(DefaultLifecyclePhase.java:225)
at org.mule.lifecycle.RegistryLifecycleManager$RegistryLifecycleCallback.onTransition(RegistryLifecycleManager.java:276)
at org.mule.lifecycle.RegistryLifecycleManager.invokePhase(RegistryLifecycleManager.java:155)
at org.mule.lifecycle.RegistryLifecycleManager.fireLifecycle(RegistryLifecycleManager.java:126)
at org.mule.registry.AbstractRegistryBroker.fireLifecycle(AbstractRegistryBroker.java:80)
at org.mule.registry.MuleRegistryHelper.fireLifecycle(MuleRegistryHelper.java:120)
at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(MuleContextLifecycleManager.java:94)
at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(MuleContextLifecycleManager.java:90)
at org.mule.lifecycle.MuleContextLifecycleManager.invokePhase(MuleContextLifecycleManager.java:72)
at org.mule.lifecycle.MuleContextLifecycleManager.fireLifecycle(MuleContextLifecycleManager.java:64)
at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:250)
at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:151)
... 4 more
Caused by: org.mule.api.lifecycle.LifecycleException: Failed to start Quartz receiver
at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(AbstractLifecycleManager.java:156)
at org.mule.transport.ConnectableLifecycleManager.fireStartPhase(ConnectableLifecycleManager.java:51)
at org.mule.transport.AbstractTransportMessageHandler.start(AbstractTransportMessageHandler.java:318)
at org.mule.transport.AbstractConnector.registerListener(AbstractConnector.java:1259)
at org.mule.endpoint.DefaultInboundEndpoint.start(DefaultInboundEndpoint.java:108)
... 27 more
Caused by: org.mule.api.endpoint.EndpointException: Failed to start Quartz receiver
at org.mule.transport.quartz.QuartzMessageReceiver.doStart(QuartzMessageReceiver.java:195)
at org.mule.transport.AbstractMessageReceiver.doStartHandler(AbstractMessageReceiver.java:484)
at org.mule.transport.AbstractTransportMessageHandler$3.onTransition(AbstractTransportMessageHandler.java:322)
at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(AbstractLifecycleManager.java:141)
... 31 more
Caused by: java.lang.IllegalArgumentException: Job name cannot be empty.
at org.quartz.JobDetail.setName(JobDetail.java:192)
at org.mule.transport.quartz.QuartzMessageReceiver.doStart(QuartzMessageReceiver.java:95)
... 34 more
Here's the xml file :
<?xml version="1.0" encoding="UTF-8"?>
<mule 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/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 ">
<flow name="crontestFlow1" doc:name="crontestFlow1">
<quartz:inbound-endpoint jobName="test_job" cronExpression="0 0/100 * * * ?" responseTimeout="10000" doc:name="Price File Report Quartz Job" >
<quartz:event-generator-job>
</quartz:event-generator-job>
</quartz:inbound-endpoint>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
Notice that your jobName is not empty . The issue is with underscore . you can not have underscore in jobName property. Just remove underscore from jobName and it will run fine.You can not have white space characters in job name eitherHere's the
bug. Post Comments And Suggestions !!