Instantly share code, notes, and snippets.

View target.xml
<flow name="getStockInfo">
<http:listener path="stock" method="GET" config-ref="httpListener">
<http:response>
<http:body>
<![CDATA[
%dw 2.0
output application/json
---
{
"ticker": attributes.queryParams.ticker,
View persons.xml
<flow name="prersons">
<http:listener path="person" method="POST" config-ref="httpListener" />
<foreach collection="#[payload.persons]">
<choice>
<when expression="#[payload.age > 21"]>
<logger message="#['$(payload.name) is an adult']" />
</when>
<otherwise>
<logger message="#['$(payload.name) is a minor.']" />
</otherwise>
View persons.json
{
persons: [
{
name: "John Doe",
age: 35
},
{
name: "Jane Doe",
age: 32
},
View idempotent.xml
<idempotent-message-validator idExpression="#[payload]" valueExpression="#[payload]">
<os:private-object-store
entryTtl="20"
entryTtlUnit="MILLISECONDS"
maxEntries="20"
persistent="false"
expirationInterval="20"
expirationIntervalUnit="MILLISECONDS"/>
</idempotent-message-validator>
View sfdc.xml
<sfdc:config-with-oauth name="salesforce-oauth"
consumerKey="${salesforce.consumerKey}"
consumerSecret="${salesforce.consumerSecret}">
<sfdc:oauth-callback-config domain="localhost" localPort="8082"
remotePort="8082" path="callback" connector-ref="HTTP_HTTPS" />
<sfdc:oauth-store-config objectStore="tokensStore" />
</sfdc:config-with-oauth>
View global.xml
<os:object-store name="tokensStore"
entryTtl="1"
entryTtlUnit="HOURS"
maxEntries="100"
persistent="true"
expirationInterval="30"
expirationIntervalUnit="MINUTES" />
View retrieve-default2.xml
<os:retrieve key="state">
<os:default-value>
<![CDATA[#[
output application/json
---
{ "id": attributes.queryParams.id,
"timestamp": now(),
"name": payload.name
}
]]]>
View retrieve-default.xml
<os:retrieve key="timestamp">
<os:default-value>#[now()]</os:default-value>
</os:retrieve>
View store-default.xml
<os:store key="state">
<os:value>
<![CDATA[#[
output application/json
---
{ "id": attributes.queryParams.id,
"timestamp": now(),
"name": payload.name
}
]]]>