Mule - 消息已被过滤器拒绝。消息有效负载的类型为:byte []

时间:2014-03-21 12:32:40

标签: exception mule mule-studio payload

我在Mule中有一个流程,我正在读取文件,记录它的内容然后输出到新文件。每次我尝试运行流程时,我都会在Mule识别出输入文件后立即收到以下错误:

INFO  2014-03-21 12:23:45,706 [[processes].inputFileConnector.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: /input/file_203812.dat
ERROR 2014-03-21 12:23:45,725 [[processes].inputFileConnector.receiver.01] org.mule.exception.CatchMessagingExceptionStrategy: 
********************************************************************************
Message               : Message has been rejected by filter. Message payload is of type: byte[]
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Message has been rejected by filter. Message payload is of type: byte[] (org.mule.api.routing.filter.FilterUnacceptedException)
  org.mule.routing.MessageFilter:100 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/routing/filter/FilterUnacceptedException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.routing.filter.FilterUnacceptedException: Message has been rejected by filter. Message payload is of type: byte[]
    at org.mule.routing.MessageFilter.filterUnacceptedException(MessageFilter.java:100)
    at org.mule.processor.AbstractFilteringMessageProcessor.handleUnaccepted(AbstractFilteringMessageProcessor.java:62)
    at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:48)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

我一直试图解决这个问题一段时间没有成功,所以任何帮助都会受到赞赏。这是我的配置文件的副本供参考:

<file:connector name="outputFileConnector" doc:name="File"/>
<file:connector name="inputFileConnector" workDirectory="/processing" 
    workFileNamePattern="#[message.outboundProperties.originalFilename]" moveToDirectory="/backup" 
    moveToPattern="#[function:datestamp:yyyyMMddHHmmssSSS]_#[message.outboundProperties.originalFilename]"
    streaming="false" doc:name="File"/>

<flow name="MainFlow" doc:name="MainFlow">

    <file:inbound-endpoint name="b2bFileEndpoint" path="/input" pollingFrequency="1000" connector-ref="inputFileConnector" doc:name="Input Trigger">
        <file:filename-regex-filter pattern="file_\d{6}.dat" caseSensitive="true"/> 
    </file:inbound-endpoint>

    <object-to-string-transformer doc:name="Object to String"/>      
    <logger level="INFO" message="#[payload]" doc:name="Debug"/>

    <file:outbound-endpoint path="/output" connector-ref="outputFileConnector" responseTimeout="10000" doc:name="File"/>

    <!-- Error handling -->
    <catch-exception-strategy doc:name="Catch Exception Strategy">
        <logger level="ERROR" message="There has been an error" doc:name="Logger"/>
    </catch-exception-strategy>

</flow>

更新

奇怪的是,如果我将moveToPattern更改为:#[message.outboundProperties.orginalFilename],问题就会消失。这不是一个选项,因为我需要处理的文件附加日期戳。现在对这个问题非常困惑......

1 个答案:

答案 0 :(得分:0)

看到这是我的一个例子...它工作正常...请根据您的要求修改并添加catch块: -

<file:connector name="File_Input_Global" workDirectory="E:\backup\test_workingDir" workFileNamePattern="#[function:datestamp:dd-MM-yyyy]_#[header:originalFilename].dat" autoDelete="false" streaming="true" validateConnections="true" doc:name="File"/>
<file:connector name="File_output_Global" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="FileRegularExpFlow1" doc:name="FileRegularExpFlow1">
    <file:inbound-endpoint path="E:\backup\test" responseTimeout="10000" connector-ref="File_Input_Global" doc:name="File">
        <file:filename-regex-filter pattern="aa.txt" caseSensitive="false"/>
    </file:inbound-endpoint>
    <file:outbound-endpoint path="E:\backup\test_out" outputPattern="#[header:originalFilename]" responseTimeout="10000" connector-ref="File_output_Global" doc:name="File"/>
</flow>

您可以看到工作目录中的文件包含日期戳和原始文件名...如果有帮助,请投票给答案