
Hi,
I'm strugglling with a design and concept of trying to achieve something in Mule. I'm sure its possible, but i'm trying to stand something up quickly to test something.
What I have, is a CSV with 3 columns. I'm trying to pass each row, in turn, to a http REST interface and store the results.
The REST interface has multiple inputs, start location, end location 1, end location 2, end location 3 (depending on batch size) etc.
I want to pass row 1, columns 2 and 3 as the start location, and pass the end locations as row 1 columns 2 and 3 to end of file.
So far, I have the file input, transforming the message and the request/response and then the output to a file.
The parts i'm struggling with though, are processing each row, not passing over the entire csv, and then logging the responses for each REST call.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" 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.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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd">
<http:request-config name="REST Interface" host="matrix.blah.com" port="80" doc:name="HTTP Request Configuration"/>
<file:connector name="File" readFromDirectory="C:\tmp\input\" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="matrixFlow">
<file:inbound-endpoint path="C:\tmp\input" moveToDirectory="C:\tmp\input\processed" connector-ref="File" responseTimeout="10000" doc:name="File"/>
<dw:transform-message doc:name="Transform Message" metadata:id="23175381-2b5d-4aa8-987f-c7a3f9a932fd">
<dw:input-payload mimeType="application/csv"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload map
{
REGION_REF: $.REGION_REF,
LON: $.LON,
LAT: $.LAT
}]]></dw:set-payload>
</dw:transform-message>
<logger message="Transformation of file set to # [payload]" level="INFO" doc:name="Logger"/>
<http:request config-ref="Here.com" path="/routing/calculatematrix.json?" method="GET" doc:name="Matrix Request">
<http:request-builder>
<http:query-param paramName="app_id" value="?????????"/>
<http:query-param paramName="app_code" value="??????"/>
<http:query-param paramName="mode" value="fastest;car;traffic:disabled"/>
<http:query-param paramName="matrixAttributes" value="summary"/>
<http:query-param paramName="summaryAttributes" value="traveltime"/>
<http:query-param paramName="start0" value="52.5,13.4"/> --- Need this to be row1, column 2 & 3
<http:query-param paramName="destination0" value="52.5,13.43"/>
<http:query-param paramName="destination1" value="52.5,13.46"/> --need this to be row 1-50 of file for columns 2 and 3 in a batch all the way to eof.
</http:request-builder>
</http:request>
<logger message="# [message]" level="INFO" doc:name="Here.com Response"/>
<file:outbound-endpoint path="C:\tmp\output" outputPattern="output.txt" responseTimeout="10000" doc:name="File"/>
</flow>
</mule>
I'm aware its a big ask, as the actual solution i'm sure is quite a bit of work to log errors etc, but i'm just trying to test with a small batch just to see how it works.

Hi Jesus,
Indeed it is, well spotted. The input is basically:
REGION_REF,LON,LAT
e.g US.WV.25063,-80.948975,38.590197
Thanks,
Gareth