user1820620
user1820620

Reputation: 702

Mule - running more instance of the same flow simultaneously

I have a complex flow that can be drastically reduced to this one (for the sake of this question):

    <?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:context="http://www.springframework.org/schema/context" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ajax="http://www.mulesoft.org/schema/mule/ajax" 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="EE-3.4.0" 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
http://www.mulesoft.org/schema/mule/ajax http://www.mulesoft.org/schema/mule/ajax/current/mule-ajax.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<quartz:connector name="quartzConnector_vm" validateConnections="true" doc:name="Quartz">  
     <quartz:factory-property key="org.quartz.scheduler.instanceName" value="MuleScheduler1"/>  
     <quartz:factory-property key="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool"/>  
     <quartz:factory-property key="org.quartz.threadPool.threadCount" value="3"/>  
     <quartz:factory-property key="org.quartz.scheduler.rmi.proxy" value="false"/>  
     <quartz:factory-property key="org.quartz.scheduler.rmi.export" value="false"/>  
     <quartz:factory-property key="org.quartz.jobStore.class" value="org.quartz.simpl.RAMJobStore"/>  
   </quartz:connector>
    <context:property-placeholder location="my-mule-app.properties"/>  
    <flow name="testQuartzFlow1" doc:name="testQuartzFlow1">
        <quartz:inbound-endpoint cronExpression="${SCHEDULE_FREQUENCY}" responseTimeout="10000" connector-ref="quartzConnector_vm" doc:name="Event_generator" jobName="pollastro">
            <quartz:event-generator-job groupName="DEFAULT" jobGroupName="DEFAULT">
                <quartz:payload>"${WHOAMI}"</quartz:payload>
            </quartz:event-generator-job>
        </quartz:inbound-endpoint>
        <logger level="INFO" doc:name="Logger" message="#[message:payload]"/>
    </flow>  
</mule>

Basically a quartz component that every certain amount of minutes (read from a property file) fires a logger that logs another data taken from a property file.

What I want is:

  1. To run more instance of the same flow simultaneously, each instance with a different set of properties (to be contained on a file)

  2. To be able, in some way, to stop/start the a certain instance.

How can I do this? Thank you

Upvotes: 1

Views: 699

Answers (1)

David Dossot
David Dossot

Reputation: 33413

For 1), I've heard of an experimental module that allows using configuration templates and substitute values in the template at start-up time. I unfortunately can't locate it for now but will update my answer if I can.

Alternatively, if what's happening after each quartz:inbound-endpoints is the same, you could wrap them in a <composite-source> and programatically add more endpoints to this source at start-up time.

Other alternatives are to completely build the flow with custom code or even generate the XML configuration based on the properties files as a pre-Mule boot phase.

For 2) You can control endpoints (connect/disconnect) over JMX so, in theory, you should be able to control the Quartz endpoints that way.

Upvotes: 1

Related Questions