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



我创建了一个简单的流程,该流创建了一个名称列表来转换它。转换器抛出 IllegalArgumentException 来中断流。不幸的是,即使抛出异常,failure表达式也不起作用。它与任何例外都不匹配。我已经包括了流量和变压器。

这是我的配置:

<?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

失败表达式

指定一个表达式,当该表达式的计算结果为 true 时,该表达式确定 一条路由的处理是失败的。如果没有表达式 但是,只有异常将被视为处理失败。

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

最新更新