Skip to content

Instantly share code, notes, and snippets.

@andyevans
Last active June 29, 2017 06:27
Show Gist options
  • Save andyevans/009e0fb40da39bf65a22 to your computer and use it in GitHub Desktop.
Save andyevans/009e0fb40da39bf65a22 to your computer and use it in GitHub Desktop.
Simple Mule Flow using Amazon SQS
<flow name="sqs-http-async-four" doc:name="sqs-http-async-four" processingStrategy="asynchronous">
<sqs:receive-messages config-ref="sqs-test-flow-in" doc:name="Receive Message" preserveMessages="true"/>
<choice doc:name="Choice">
<when expression="#[message.inboundProperties['ApproximateReceiveCount']&gt;=${sqs.test.default.maxretries}]">
<logger level="INFO" doc:name="Log Max Retries Exceeded"/>
<sqs:send-message config-ref="sqs-test-flow-dlq" doc:name="Push to dlq"/>
</when>
<otherwise>
<http:outbound-endpoint exchange-pattern="request-response" host="${http.outbound.host}" port="${http.outbound.port}" path="${http.outbound.path}" method="POST" responseTimeout="${http.timeout}" doc:name="Invoke HTTP Endpoint"/>
<choice doc:name="Choice">
<when expression="#[message.inboundProperties['http.status']=='200']">
<logger level="INFO" doc:name="Log Success"/>
</when>
<otherwise>
<logger level="INFO" doc:name="Log Business Error"/>
<sqs:send-message config-ref="sqs-test-flow-dlq" doc:name="Push to dlq"/>
</otherwise>
</choice>
</otherwise>
</choice>
<sqs:delete-message config-ref="sqs-test-flow-in" doc:name="Delete Input Message"/>
<choice-exception-strategy doc:name="Choice Exception Strategy">
<catch-exception-strategy doc:name="Catch_Exception_Strategy" when="#[exception.causedBy(java.net.SocketTimeoutException)]">
<logger message="A timeout exception has occurred: #[message.exception] Message will be retried." level="INFO" doc:name="Log Timeout Exception"/>
</catch-exception-strategy>
<catch-exception-strategy doc:name="Catch_Exception_Strategy">
<logger message="An unhandled exception has occurred: #[message.exception] Pushing message to DLQ." level="INFO" doc:name="Log Exception"/>
<sqs:send-message config-ref="sqs-test-flow-dlq" doc:name="Push to dlq"/>
<sqs:delete-message config-ref="sqs-test-flow-in" doc:name="Delete Input Message"/>
</catch-exception-strategy>
</choice-exception-strategy>
</flow>
@rriviere
Copy link

awesome stuff Andy. Is there any chance of seeing your config.xml files. i.e. sqs-test-flow-in and sqs-test-flow-dlq. That along with the properties files you have provided is the last piece of the puzzle for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment