问题描述
使用骡子工作室
版本:3.5.0内部版本号:201402101410
Version: 3.5.0Build Id: 201402101410
我有一个非常简单的流程.我需要从一个 ftp 服务器中获取一个文件并将其传输到另一个 ftp 服务器.当文件写入目标时,文件名看起来像某种 UUId 而不是原始文件名.如何获取要执行的文件名?我试过 #[header:originalFilename] 但这会引发错误,所以我认为它可能仅适用于文件连接器.这是我的流程:
I have a very simple flow. I need to pick up a file from one ftp server and transfer it to another ftp server. When the file is written to the target, the filename looks like some kind of UUId rather than the original file name. How do I get the file name to carry through? I have tried #[header:originalFilename] but that throws an error so I assume that maybe it is only for file connectors. Here is my flow:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" 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:context="http://www.springframework.org/schema/context" version="CE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<context:property-placeholder location="environment.properties"/>
<flow name="sli-ftpFlow1" doc:name="sli-ftpFlow1">
<ftp:inbound-endpoint host="${local.ftp.host}" port="${local.ftp.port}" path="${local.ftp.path}" user="${local.ftp.user}" password="${local.ftp.pass}" responseTimeout="10000" doc:name="FTP" pollingFrequency="${local.ftp.pollingFreq}" binary="true" passive="false"/>
<logger message="Transferring file:" level="INFO" doc:name="Logger"/>
<ftp:outbound-endpoint host="${sli.ftp.host}" port="${sli.ftp.port}" path="${sli.ftp.path}" user="${sli.ftp.user}" password="${sli.ftp.pass}" responseTimeout="10000" doc:name="FTP" outputPattern="#[header:originalFilename]"/>
</flow>
</mule>
堆栈跟踪:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'sli-ftp' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2014-03-19 22:10:38,058 [[sli-ftp].sli-ftpFlow1.stage1.02] INFO org.mule.api.processor.LoggerMessageProcessor - Transferring file:
2014-03-19 22:10:38,071 [[sli-ftp].connector.ftp.mule.default.dispatcher.01] INFO org.mule.lifecycle.AbstractLifecycleManager - Initialising: 'connector.ftp.mule.default.dispatcher.1035665885'. Object is: FtpMessageDispatcher
2014-03-19 22:10:38,071 [[sli-ftp].connector.ftp.mule.default.dispatcher.01] INFO org.mule.lifecycle.AbstractLifecycleManager - Starting: 'connector.ftp.mule.default.dispatcher.1035665885'. Object is: FtpMessageDispatcher
2014-03-19 22:10:38,078 [[sli-ftp].connector.ftp.mule.default.dispatcher.01] ERROR org.mule.exception.DefaultMessagingExceptionStrategy -
********************************************************************************
Message : Streaming failed. Could not get output stream. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=ftp://esbuser%40newpig.com:<password>@webuatint/SLI-Mock, connector=FtpConnector
{
name=connector.ftp.mule.default
lifecycle=start
this=a40c648
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[ftp]
serviceOverrides=<none>
}
, name='endpoint.ftp.webuatint.21.SLI.Mock', mep=ONE_WAY, properties={outputPattern=#[header:originalFilename]}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: byte[]
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Expression Evaluator "header" with expression "outbound:originalFilename" returned null but a value was required. (org.mule.api.expression.RequiredValueException)
org.mule.expression.ExpressionUtils:239 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/RequiredValueException.html)
2. Streaming failed. Could not get output stream. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=ftp://esbuser%40newpig.com:<password>@webuatint/SLI-Mock, connector=FtpConnector
{
name=connector.ftp.mule.default
lifecycle=start
this=a40c648
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[ftp]
serviceOverrides=<none>
}
, name='endpoint.ftp.webuatint.21.SLI.Mock', mep=ONE_WAY, properties={outputPattern=#[header:originalFilename]}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: byte[] (org.mule.api.transport.DispatchException)
org.mule.transport.ftp.FtpConnector:602 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.expression.RequiredValueException: Expression Evaluator "header" with expression "outbound:originalFilename" returned null but a value was required.
at org.mule.expression.ExpressionUtils.getPropertyInternal(ExpressionUtils.java:239)
at org.mule.expression.ExpressionUtils.getPropertyWithScope(ExpressionUtils.java:67)
at org.mule.expression.ExpressionUtils.getPropertyWithScope(ExpressionUtils.java:50)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
Logger 中带有 #[header:originalFilename] 的堆栈跟踪:
Stack Trace with #[header:originalFilename] in Logger:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'sli-ftp' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2014-03-20 08:15:35,918 [[sli-ftp].sli-ftpFlow1.stage1.02] ERROR org.mule.exception.DefaultMessagingExceptionStrategy -
********************************************************************************
Message : Expression Evaluator "header" with expression "outbound:originalFilename" returned null but a value was required. (org.mule.api.expression.RequiredValueException). Message payload is of type: byte[]
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Expression Evaluator "header" with expression "outbound:originalFilename" returned null but a value was required. (org.mule.api.expression.RequiredValueException)
org.mule.expression.ExpressionUtils:239 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/RequiredValueException.html)
2. Expression Evaluator "header" with expression "outbound:originalFilename" returned null but a value was required. (org.mule.api.expression.RequiredValueException). Message payload is of type: byte[] (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:35 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.expression.RequiredValueException: Expression Evaluator "header" with expression "outbound:originalFilename" returned null but a value was required.
at org.mule.expression.ExpressionUtils.getPropertyInternal(ExpressionUtils.java:239)
at org.mule.expression.ExpressionUtils.getPropertyWithScope(ExpressionUtils.java:67)
at org.mule.expression.ExpressionUtils.getPropertyWithScope(ExpressionUtils.java:50)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
推荐答案
使用 MEL:#[message.inboundProperties.originalFilename].
Use MEL: #[message.inboundProperties.originalFilename].
我认为范围是问题所在.
I think the scope is the issue.
这在 3.4 中有所改变 -http://www.mulesoft.org/documentation/display/current/Mule+ESB+3.4.0+Release+Notes
This was changed in 3.4 -http://www.mulesoft.org/documentation/display/current/Mule+ESB+3.4.0+Release+Notes
Mule 3.4+ originalFilename 在入站范围内.所以使用:#[message.inboundProperties.originalFilename]
Mule 3.4+ originalFilename is in the inbound scope. So use: #[message.inboundProperties.originalFilename]
骡子
Mule < 3.4 originalFilename is in the outbound scope. So use: #[message.outboundProperties.originalFilename]
问题记录在此处:https://www.mulesoft.org/jira/browse/MULE-6743
这篇关于将原始文件名携带到 FTP 端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!