Paramita Das
Paramita Das

Reputation: 23

How to do error handling in Clone-Aggregator mediator in WSO2 Micro Integrator?

I am new to WSO2, working with Micro Integrator. I am trying to achieve scatter-gather pattern in wso2. However I am not able to handle the error. For example, I am trying to call two endpoints with the same message but if one of the endpoints returns HTTP_SC != 200 then the error message will be returned as a json message {"Error": ERROR_DETAIL }Below is the code snippet I have written - Main Flow :--

<resource methods="POST GET" uri-template="/clone">
<inSequence>
    <sequence key="Sequence"/>
</inSequence>
<outSequence>
    <property name="info" scope="default">
        <Aggregated_Response/>
    </property>
    <aggregate>
        <completeCondition>
            <messageCount max="-1" min="-1"/>
        </completeCondition>
        <onComplete aggregateElementType="root" enclosingElementProperty="info" expression="json-eval($)">
            <respond/>
        </onComplete>
    </aggregate>
</outSequence>
<faultSequence/>

Sequence Flow :--

<sequence name="Sequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<clone>
    <target>
        <endpoint>
            <http method="post" uri-template="http://run.mocky.io/XXXX">
                <suspendOnFailure>
                    <initialDuration>-1</initialDuration>
                    <progressionFactor>1</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                    <retriesBeforeSuspension>0</retriesBeforeSuspension>
                </markForSuspension>
            </http>
        </endpoint>
    </target>
    <target>
        <endpoint>
            <http method="post" uri-template="http://run.mocky.io/ABC">
                <suspendOnFailure>
                    <initialDuration>-1</initialDuration>
                    <progressionFactor>1</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                    <retriesBeforeSuspension>0</retriesBeforeSuspension>
                </markForSuspension>
            </http>
        </endpoint>
    </target>
</clone>

Many thanks !!!

Upvotes: 0

Views: 29

Answers (0)

Related Questions