I am using WSO2 ESB as RabbitMQ consumer: I have a proxy service which consumes messages from rabbit queue and sends it to my backend service using http endpoint. Everything works fine and messages are successfully delivered to my backend.
The problem is that my backend service can fail sometimes and I would like to know about that fact and save this information in ESB log for example.
For example I would like to log HTTP/1.1 500 Internal Server Error
errors.
How can I achieve this?
I found out that I should use FORCE_ERROR_ON_SOAP_FAULT
property in my in sequence but it does not work in my case.
My consumer proxy configuration looks as follows:
<proxy name="AMQPProxy" startOnLoad="true" statistics="enable"
trace="enable" transports="rabbitmq">
<description/>
<target>
<inSequence onError="fault">
<log level="full"/>
<property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
<property name="OUT_ONLY" value="true"/>
<property name="FORCE_ERROR_ON_SOAP_FAULT"
scope="default" type="STRING" value="true"/>
<send>
<endpoint key="SampleEndPoint"/>
</send>
</inSequence>
<outSequence>
<log level="full">
<property name="MESSAGE" value="outSequence"/>
</log>
<drop/>
</outSequence>
</target>
<parameter name="rabbitmq.queue.routing.key">route</parameter>
<parameter name="rabbitmq.exchange.name">exchange</parameter>
<parameter name="rabbitmq.queue.name">queue</parameter>
<parameter name="rabbitmq.connection.factory">AMQPConnectionFactory</parameter>
</proxy>
How should I configure it to handle 5xx errors?
Edit:
I finally solve it using following proxy configuration:
<proxy name="AMQPProxy" startOnLoad="true" statistics="enable"
trace="enable" transports="rabbitmq">
<description/>
<target>
<inSequence onError="fault">
<log level="full"/>
<property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
<send>
<endpoint key="SampleEndPoint"/>
</send>
</inSequence>
<outSequence>
<log>
<property expression="$axis2:HTTP_SC" name="Status Code"/>
</log>
<filter regex="^((?!(200|202)).)*$" source="$axis2:HTTP_SC">
<then>
<property expression="$axis2:HTTP_SC" name="ERROR_CODE"/>
<property expression="$axis2:HTTP_SC_DESC" name="ERROR_MESSAGE"/>
<sequence key="fault"/>
</then>
</filter>
<drop/>
</outSequence>
</target>
<parameter name="rabbitmq.queue.routing.key">route</parameter>
<parameter name="rabbitmq.exchange.name">exchange</parameter>
<parameter name="rabbitmq.queue.name">queue</parameter>
<parameter name="rabbitmq.connection.factory">AMQPConnectionFactory</parameter>
</proxy>