Skip to content

Instantly share code, notes, and snippets.

@ricston-git
Created July 28, 2015 09:08
Show Gist options
  • Save ricston-git/1c6fe663c0a8394cebdc to your computer and use it in GitHub Desktop.
Save ricston-git/1c6fe663c0a8394cebdc to your computer and use it in GitHub Desktop.
<mongo:config name="mongoDb" database="testDb" host="localhost" port="27017" />
<flow name="setNullComponent">
<expression-transformer expression="org.mule.transport.NullPayload.getInstance()" evaluator="groovy"></expression-transformer>
</flow>
<flow name="getTestCollectionFlow">
<vm:inbound-endpoint path="getTestCollection" exchange-pattern="request-response" />
<!-- workaround for mongo throwing exception when it does not find an entry in the db -->
<first-successful>
<!-- try query -->
<mongo:find-one-object collection="testCollection" config-ref="mongoDb" query="#[string:{ &quot;id&quot; : #[bean:id] } ]" />
<!-- if previous call throws exception, set the payload to NullPayload -->
<flow-ref name="setNullComponent" />
</first-successful>
</flow>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment