【问题标题】:Mule XML File input parse flowMule XML 文件输入解析流程
【发布时间】:2013-12-03 11:34:58
【问题描述】:

我有以下 Mule 流程:

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

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"    
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
xmlns:file="http://www.mulesoft.org/schema/mule/file" 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="EE-3.4.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.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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/ee/tracking   
http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">

<mulexml:dom-to-xml-transformer name="domToXml"/>

<flow name="SplitterFlow1" doc:name="SplitterFlow1">
<file:inbound-endpoint path="D:\WORK\Input"
responseTimeout="10000" doc:name="File"  encoding="UTF-8"  tracking:enable-default-events="true"   
moveToDirectory="D:\WORK\Output"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<byte-array-to-string-transformer doc:name="Byte Array to String" />
<splitter evaluator="xpath" expression="/Invoices/invoice"
doc:name="Splitter"/>
<transformer ref="domToXml" doc:name="Transformer Reference"/>
<tracking:custom-event event-name="Invoice ID" doc:name="Custom Business event">
<tracking:meta-data key="Invoice ID" value="#[message.payload]"/>
</tracking:custom-event>
<logger level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="D:\WORK\Output"
outputPattern="#[function:dateStamp:dd-MM-yyyy-HH.mm.ss]-#[header:OUTBOUND:MULE_CORRELATION_SEQUENCE]"
responseTimeout="10000" doc:name="File"></file:outbound-endpoint>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<component doc:name="Java"    
class="no.schibsted.exception_strategy.file.Validationfailure.AxaptaValidationFailure"/>
</catch-exception-strategy>
</flow>
</mule>

我需要在以后的输入 xml 文件中进行拆分和解析。如果文件由于某些原因无效, 我需要捕获异常并将文件移动到特殊文件夹中。当我尝试使用 AxaptaValidationFailure Java 组件,我发现抛出异常时输入文件从输入文件夹中消失了。

public class AxaptaValidationFailure implements Callable{

protected transient Log logger = LogFactory.getLog(getClass());

private File currentFile;
private File moveToOnClose;

@Override
public Object onCall(MuleEventContext eventContext) throws Exception {

MuleMessage message = eventContext.getMessage();
Object originalFilenameProperty = message.getInboundProperty("originalFilename");

currentFile = new File("d:\\WORK\\Input\\"+ originalFilenameProperty);

moveToOnClose = new File("d:\\WORK\\Output_Validation_Failure\\"+ originalFilenameProperty);

if (!FileUtils.moveFileWithCopyFallback(currentFile, moveToOnClose))
{
logger.warn(String.format("Failed to move file from %s to %s\n", currentFile.getPath(), 
moveToOnClose.getPath()));
}       
return originalFilenameProperty;
}
}

线

currentFile = new File("d:\WORK\Input\"+ originalFilenameProperty);

找不到输入文件

请告知,提前谢谢。

【问题讨论】:

    标签: file parsing mule endpoint


    【解决方案1】:

    你试过了吗:

    currentFile = new File("D:\WORK\Input\"+ originalFilenameProperty);
    

    即驱动器号的大写“D”?

    【讨论】:

      猜你喜欢
      • 2016-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-20
      • 2011-12-23
      • 2013-09-02
      • 1970-01-01
      相关资源
      最近更新 更多