为什么特殊字符会出现在文件中?

时间:2016-09-23 17:11:59

标签: mule mule-component anypoint-studio

我有以下配置文件, 1)选择文件并将内容发送到活动的mq。 2)从活动mq接收并将其写入文件  但是一旦写完,我就会在文件中得到一些特殊字符 “¬íssrjava.util.ArrayListxÒ™ÇaIsizexp w ur [B¬óøTàxp`”。

为什么会这样?

<mule>
<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="activemqFlow">
    <file:inbound-endpoint path="D:\mule\input" responseTimeout="10000" doc:name="File"/>
    <set-property propertyName="fileName" value="#[message.inboundProperties.originalFilename]" doc:name="Property"/>
    <jms:outbound-endpoint queue="logfilequeue" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
<flow name="JmsInboundFlow">
    <jms:inbound-endpoint queue="logfilequeue" connector-ref="Active_MQ" doc:name="JMS">
        <jms:client-ack-transaction acti on="NONE"/>
    </jms:inbound-endpoint>
    <logger message="#[payload.toString()]" level="INFO" doc:name="Logger"/>
    <file:outbound-endpoint path="D:\mule\output" responseTimeout="10000" doc:name="File" outputPattern="#[message.inboundProperties.fileName]"/>
</flow>

1 个答案:

答案 0 :(得分:0)

您需要在文件入站端点之后使用<object-to-string-transformer doc:name="Object to String"/>,如下所示: -

<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="activemqFlow">
    <file:inbound-endpoint path="D:\mule\input" responseTimeout="10000" doc:name="File"/>
    <object-to-string-transformer doc:name="Object to String"/>
    <set-property propertyName="fileName" value="#[message.inboundProperties.originalFilename]" doc:name="Property"/>
    <jms:outbound-endpoint queue="logfilequeue" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
<flow name="JmsInboundFlow">
    <jms:inbound-endpoint queue="logfilequeue" connector-ref="Active_MQ" doc:name="JMS">
        <jms:client-ack-transaction acti on="NONE"/>
    </jms:inbound-endpoint>
    <logger message="#[payload.toString()]" level="INFO" doc:name="Logger"/>
    <file:outbound-endpoint path="D:\mule\output" responseTimeout="10000" doc:name="File" outputPattern="#[message.inboundProperties.fileName]"/>
</flow>