Exception handling 即使出现异常,仍继续Mule(3.3)流程

Exception handling 即使出现异常,仍继续Mule(3.3)流程,exception-handling,error-handling,esb,mule,Exception Handling,Error Handling,Esb,Mule,Mule 3.3.0 我有一个拆分有效负载的流。 然后,每个项都经过一个自定义转换器,如果项的格式不正确,该转换器可能会抛出一个异常。 我有一个捕获异常策略来将错误项记录到文件中。 我希望流程继续处理其余的项目,据我所知,这应该是预期的行为。 问题是流量停止。 我附加了一个简单的测试流和一个简单的测试文件。 该文件是一个csv文件,有2行,每行有3个字段。 我正在使用groovy脚本,首先将文件拆分为行,然后将每行拆分为字段。 我还使用groovy脚本模拟字段格式错误时的异常。在这种情况下,如果

Mule 3.3.0
我有一个拆分有效负载的流。
然后,每个项都经过一个自定义转换器,如果项的格式不正确,该转换器可能会抛出一个异常。
我有一个捕获异常策略来将错误项记录到文件中。
我希望流程继续处理其余的项目,据我所知,这应该是预期的行为。
问题是流量停止。

我附加了一个简单的测试流和一个简单的测试文件。 该文件是一个csv文件,有2行,每行有3个字段。 我正在使用groovy脚本,首先将文件拆分为行,然后将每行拆分为字段。 我还使用groovy脚本模拟字段格式错误时的异常。在这种情况下,如果字段是单词“再见”,它将抛出RuntimeException。 如果您测试此流,您将看到异常后的其余字段将不会得到处理(即在本例中记录)。 在这个特殊的例子中,catch异常策略甚至不会触发

输入文件:

hello,cruel,world goodbye,cruel,world 你好,残酷的世界 再见,残酷的世界 测试流

TestCase.mflow

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:file="http://www.mulesoft.org/schema/mule/file"
    xmlns:vm="http://www.mulesoft.org/schema/mule/vm" 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" version="CE-3.3.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd 
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 ">

    <file:connector name="inputFileConnector" autoDelete="true"
        streaming="false" validateConnections="true" doc:name="File" fileAge="60000"
         readFromDirectory="#{systemProperties['user.home']}"/>
    <catch-exception-strategy name="Catch_Exception_Strategy">
        <logger message="!!!!! Exception Handler !!!!!" level="INFO" doc:name="Logger"/>
    </catch-exception-strategy>

    <flow name="TestCaseFlow1" doc:name="TestCaseFlow1">
        <file:inbound-endpoint path="#{systemProperties['user.home']}"
            responseTimeout="10000" doc:name="Input File" fileAge="100" connector-ref="inputFileConnector">
            <file:filename-regex-filter pattern="input.csv"
                caseSensitive="false" />
        </file:inbound-endpoint>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <scripting:component doc:name="Groovy">
            <scripting:script engine="Groovy">
                <scripting:text><![CDATA[return payload.split('\n');]]></scripting:text>
            </scripting:script>
        </scripting:component>
        <collection-splitter doc:name="Collection Splitter"/>
        <scripting:component doc:name="Groovy">
            <scripting:script engine="Groovy">
                <scripting:text><![CDATA[return payload.split(',');]]></scripting:text>
            </scripting:script>
        </scripting:component>
        <collection-splitter doc:name="Collection Splitter"/>
        <scripting:component doc:name="Groovy">
            <scripting:script engine="Groovy">
                <scripting:text><![CDATA[if (payload.equals('goodbye')) {
                            throw new java.lang.RuntimeException('Dang!');
                        }
                        return payload]]></scripting:text>
            </scripting:script>
        </scripting:component>
        <logger message=">>>>>>>>>>>>>>>>>> #[payload]" level="INFO" doc:name="Logger" />
    </flow>
</mule>

我首先要做的是分离主流程。在每个
集合拆分器
放置JMS或VM
出站端点
后,这样每个消息都将有自己的线程,如果其中一个失败,其他消息将不会受到影响

<flow name="flow1">
  <file:inbound-endpoint path="#{systemProperties['user.home']}"
      responseTimeout="10000" doc:name="Input File" fileAge="100" connector-ref="inputFileConnector">
      <file:filename-regex-filter pattern="input.csv"
      caseSensitive="false" />
  </file:inbound-endpoint>
  <byte-array-to-string-transformer doc:name="Byte Array to String"/>
  <scripting:component doc:name="Groovy">
      <scripting:script engine="Groovy">
      <scripting:text><![CDATA[return payload.split('\n');]]></scripting:text>
      </scripting:script>
  </scripting:component>
  <collection-splitter doc:name="Collection Splitter"/>
  <vm:outbound-endpoint path="toFlow2"/>
</flow>

 <flow name="flow2">
  <vm:inbound-endpoint path="toFlow2"/>
  <scripting:component doc:name="Groovy">
      <scripting:script engine="Groovy">
      <scripting:text><![CDATA[return payload.split(',');]]></scripting:text>
      </scripting:script>
  </scripting:component>
  <collection-splitter doc:name="Collection Splitter"/>
  <vm:outbound-endpoint path="toFlow3"/>
</flow>

 <flow name="flow3">
  <vm:inbound-endpoint path="toFlow3"/>
  <scripting:component doc:name="Groovy">
      <scripting:script engine="Groovy">
      <scripting:text><![CDATA[if (payload.equals('goodbye')) {
              throw new java.lang.RuntimeException('Dang!');
          }
          return payload]]></scripting:text>
      </scripting:script>
  </scripting:component>
  <logger message=">>>>>>>>>>>>>>>>>> #[payload]" level="INFO" doc:name="Logger" />
</flow>

我首先要做的是分离主流程。在每个
集合拆分器
放置JMS或VM
出站端点
后,这样每个消息都将有自己的线程,如果其中一个失败,其他消息将不会受到影响

<flow name="flow1">
  <file:inbound-endpoint path="#{systemProperties['user.home']}"
      responseTimeout="10000" doc:name="Input File" fileAge="100" connector-ref="inputFileConnector">
      <file:filename-regex-filter pattern="input.csv"
      caseSensitive="false" />
  </file:inbound-endpoint>
  <byte-array-to-string-transformer doc:name="Byte Array to String"/>
  <scripting:component doc:name="Groovy">
      <scripting:script engine="Groovy">
      <scripting:text><![CDATA[return payload.split('\n');]]></scripting:text>
      </scripting:script>
  </scripting:component>
  <collection-splitter doc:name="Collection Splitter"/>
  <vm:outbound-endpoint path="toFlow2"/>
</flow>

 <flow name="flow2">
  <vm:inbound-endpoint path="toFlow2"/>
  <scripting:component doc:name="Groovy">
      <scripting:script engine="Groovy">
      <scripting:text><![CDATA[return payload.split(',');]]></scripting:text>
      </scripting:script>
  </scripting:component>
  <collection-splitter doc:name="Collection Splitter"/>
  <vm:outbound-endpoint path="toFlow3"/>
</flow>

 <flow name="flow3">
  <vm:inbound-endpoint path="toFlow3"/>
  <scripting:component doc:name="Groovy">
      <scripting:script engine="Groovy">
      <scripting:text><![CDATA[if (payload.equals('goodbye')) {
              throw new java.lang.RuntimeException('Dang!');
          }
          return payload]]></scripting:text>
      </scripting:script>
  </scripting:component>
  <logger message=">>>>>>>>>>>>>>>>>> #[payload]" level="INFO" doc:name="Logger" />
</flow>


您的有效负载是一组对象吗?你能发布你的配置吗?你的负载是一组对象吗?你能发布你的配置吗?太好了,非常感谢丹尼尔。我只是希望Mule文档更好。太棒了,非常感谢Daniel。我只是希望Mule文档更好。