Search code examples
xmlpropertieswso2wso2-enterprise-integratorwso2-micro-integrator

How to assign property values to a sequence name in WSO2 ESB


I have created a sequence named "sms-sender-api-v1-common-status-update-call-sequence" which will be called inside another sequence as below.

<property name="updateStatus" value="SUCCESS" scope="default" />
<property name="onFaultSequence" value="sms-sender-api-v1-common-send-sms-respond-sequence" scope="default" />
<sequence key="sms-sender-api-v1-common-status-update-call-sequence" />

Here I have defined a property onFaultSequence which will be used to call the onError sequence of the "sms-sender-api-v1-common-status-update-call-sequence" as below:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="sms-sender-api-v1-common-status-update-call-sequence" onError="{$ctx:onFaultSequence}" trace="disable" xmlns="http://ws.apache.org/ns/synapse">

I get the below error when checking the logs:

[2024-02-15 08:59:48,115] ERROR {MicroIntegratorRegistry} - Error while resolving the canonical path of the registry key : {$ctx:onFaultSequence} java.net.URISyntaxException: Illegal character in path at index 58: file:///home/wso2carbon/wso2mi-4.0.0/registry/governance//{$ctx:onFaultSequence}`

How to properly assign a property to onError sequence value?

I get the below error when checking the logs [2024-02-15 08:59:48,115] ERROR {MicroIntegratorRegistry} - Error while resolving the canonical path of the registry key : {$ctx:onFaultSequence} java.net.URISyntaxException: Illegal character in path at index 58: file:///home/wso2carbon/wso2mi-4.0.0/registry/governance//{$ctx:onFaultSequence}

How to properly assign a property to onError sequence value?


Solution

  • AFAIK you can't attach dynamic sequences as onError sequence. As a workaround what you can do is, create and attach a common sequence to your main flow and select the Error Sequence from within.

    <?xml version="1.0" encoding="UTF-8"?>
    <sequence name="CommonErrorHandler" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
        <log>
            <property name="MSG" value="Executing Error"/>
        </log>
        <sequence key="{$ctx:onFaultSequence}"/>
    </sequence>
    

    Then in your actual sequence attach this.

    <sequence name="sms-sender-api-v1-common-status-update-call-sequence" onError="CommonErrorHandler" trace="disable" xmlns="http://ws.apache.org/ns/synapse">