Until-Successful failureExpression条件不工作

Until-Successful failureExpression condition not working

我创建了一个简单的流程,它创建了一个名称列表并对其进行了转换。转换器抛出 IllegalArgumentException 来中断流程。不幸的是,即使抛出异常,failureExpression 也不起作用。它不匹配任何异常。我已经包括了流量和变压器。

这是我的配置:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
    xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.mulesoft.org/schema/mule/scripting    
        http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd     
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-current.xsd
        http://www.mulesoft.org/schema/mule/core   
        http://www.mulesoft.org/schema/mule/core/current/mule.xsd
        http://www.mulesoft.org/schema/mule/vm   
        http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd 
        http://www.mulesoft.org/schema/mule/http    
        http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">

    <spring:beans>
        <spring:bean name="transf" class="com.until.sucessful.tests.StringAppenderTransformer" />
        <spring:bean id="objectStore" class="org.mule.util.store.SimpleMemoryObjectStore" />
    </spring:beans>

    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" />

    <flow name="untilsuccessfultestsFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/mytest" doc:name="HTTP" />
        <splitter expression="#[xpath3('//Names')]" doc:name="Splitter" />
        <until-successful maxRetries="5" millisBetweenRetries="5000" doc:name="Until Successful" objectStore-ref="objectStore" failureExpression="#[exception is java.lang.IllegalArgumentException)]">
            <vm:outbound-endpoint path="process-vm" exchange-pattern="request-response" />
        </until-successful>
        <logger level="INFO" message="After the scoped processor :: #[payload]" doc:name="Logger" />
    </flow>

    <flow name="processorFlow">
        <vm:inbound-endpoint path="process-vm" exchange-pattern="request-response" />
        <logger level="INFO" message="Before component #[payload]" doc:name="Logger" />
        <transformer ref="transf" />
    </flow>
</mule>

这是我的变形金刚

public class StringAppenderTransformer extends AbstractTransformer {

    @Override
    protected Object doTransform(Object src, String enc) throws TransformerException {
        String payload = (String) src;
        List<String> results = new ArrayList<>();
        System.out.println("Upon entry in transformer payload is :: " + payload);
        System.out.println("About to return from transformer payload is :: " + payload.split("\s+"));
        int i = 1;
        for (String args : payload.split("\s+")) {
            System.out.println("" + i + " " + args);
            i++;
            if (args != null && args.trim().equals("")) {
                results.add(args);
            } else {
                throw new IllegalArgumentException("Break the Flow!!!!!!");
            }

        }

        return results;
    }
}

根据文档: https://docs.mulesoft.com/mule-user-guide/v/3.5/until-successful-scope

failureExpression

Specifies an expression that, when it evaluated to true, determines that the processing of one route was a failure. If no expression is provided, only an exception will be treated as a processing failure.

所以 2 个选项,删除该表达式或确保 MEL return 为真。 #[exception.causeMatches("java.lang.IllegalArgumentException")]