直到成功失败表达条件不起作用

时间:2017-04-07 20:19:41

标签: mule mule-component

我创建了一个简单的流程,它创建了一个名称列表来转换它。变换器抛出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;
    }
}

1 个答案:

答案 0 :(得分:0)

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

  

failureExpression

     

指定一个表达式,当它被计算为true时,确定   一条路线的处理失败了。如果没有表达   如果提供,只有异常将被视为处理失败。

所以2个选项,删除该表达式或确保MEL返回true。 #[exception.causeMatches(&#34; java.lang.IllegalArgumentException异常&#34)]