97008 48403
+91 40-27177600

Blog

Enabling automatic starter in Mule ESB

single-blog

From the technical center of excellence of Massil Technologies, our technology leaders make it easy to understand the complex situations you come across in Mule ESB from the experience of Massil Technologies to have countered them in their experience of working on client projects in real time. This blog addresses how to enable automatic started in Mule ESB. This blog is a part of series of blogs being authored and published by Massil Technologies for the benefit of the IT community globally.

From one of our case studies, we have come across the following requirement from the client. “Can I use the automatic starter in Mule ESB? Once the application is deployed it should automatically start and finish the flow like an auto trigger. Is this available in Mule ESB or do we need to build a custom one?”

Solution:

Our answer is Yes with a bit of customization in the Mule ESB flow. The Mule ESB flow to enable automatic starter is shown below. The suitable XML code to pull this off is also given in detail below.

Xml Code:

<?xml version=“1.0” encoding=“UTF-8”?>

<mule xmlns:scripting=“http://www.mulesoft.org/schema/mule/scripting”

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”

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”

xsi:schemaLocation=“http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.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

http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd”>

<quartz:connector name=“Quartz” validateConnections=“true” doc:name=“Quartz”>

<receiver-threading-profile maxThreadsActive=“1”/>

</quartz:connector>

<quartz:connector name=“Quartz1” validateConnections=“true” doc:name=“Quartz”/>

<flow name=“scFlow” processingStrategy=“synchronous”>

<quartz:inbound-endpoint name=“connectorname”

jobName=“inventory” repeatInterval=“30000”

responseTimeout=“10000” doc:name=“Quartz” connector-ref=“Quartz1”>

<quartz:event-generator-job>

<quartz:payload>tick-tack</quartz:payload>

</quartz:event-generator-job>

</quartz:inbound-endpoint>

<logger message=“message1” level=“INFO” doc:name=“Logger”/>

<scripting:transformer doc:name=“Script”>

<scripting:script engine=“Groovy”><![CDATA[ if(muleContext.getRegistry().lookupConnector(‘Quartz’).isStarted())

{

muleContext.getRegistry().lookupConnector(‘Quartz’).stop()

}]]></scripting:script>

</scripting:transformer>

<logger message=“Quartz stopped after 1 hit” level=“INFO” doc:name=“Logger”/>

</flow>

</mule>

After executing the above flow, we see the auto starter enabled in Mule ESB. Below is the Screenshot of the Console Data.

Hope this article from Massil Technologies was useful for you. If you have any further queries on this topic, please reach out to info@massil.tech.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Get in touch with us

Scroll to top