<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:batch="http://www.mulesoft.org/schema/mule/batch"
	xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
	xmlns:http="http://www.mulesoft.org/schema/mule/http" 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/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
    
	<!-- In this file you should declare all your inbound endpoints and from here control the access to your application -->

	<flow name="triggerFlow" processingStrategy="synchronous"  doc:description="This is the simpliest entry point to start the excecution of your Template
Here you should:
	* Define any inbound endpoint
	* Handle any input parameter and transform it into the expected format by the mainFlow
Here you should not:
	* Run validations against external systems
	* Choose flow of your application based on input parameters">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/migratecontacts" doc:name="Start Synchronization">
            <http:response-builder statusCode="200"/>
        </http:listener>

        
        <batch:execute name="syncContactBatch" doc:name="Trigger syncContactBatch"/>

        <set-payload value="&lt;body style='font-family:Courier'&gt;&lt;h1&gt;Batch Process initiated&lt;/h1&gt;&lt;b&gt;ID:&lt;/b&gt;#[payload.getId()]&lt;br/&gt;&lt;b&gt;Records to Be Processed: &lt;/b&gt;#[payload.getRecordCount()]&lt;br/&gt; &lt;b&gt;Start execution on: &lt;/b&gt;#[new java.util.Date()]&lt;/body&gt;" doc:name="set response body"/>

		
		<exception-strategy ref="defaultChoiceExceptionStrategy" doc:name="Reference Exception Strategy"/>
            
    </flow>
</mule>
