Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GETのQuery ParameterをForEachで回しながら、ログに出力するサンプル
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/json
http://www.mulesoft.org/schema/mule/json/current/mule-json.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/db
http://www.mulesoft.org/schema/mule/db/current/mule-db.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">
<flow name="GetFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/output_queries" doc:name="Recieve HTTP request" allowedMethods="GET">
</http:listener>
<logger doc:name="Log the payload" level="INFO" message="About to echo #[message.inboundProperties.'http.query.params']"/>
<!-- Query Parameter分ループする -->
<foreach collection="#[message.inboundProperties.'http.query.params'.entrySet()]" doc:name="For Each">
<!-- payload変数にQuery Parameterの1つ分が入っている -->
<logger doc:name="Log the payload" level="INFO" message="payload(#[counter]): #[payload]"/>
<logger doc:name="Log the payload" level="INFO" message="payload(#[counter]).key: #[payload.key]"/>
<logger doc:name="Log the payload" level="INFO" message="payload(#[counter]).value: #[payload.value]"/>
</foreach>
</flow>
</mule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment