将原始文件名传送到FTP端点

时间:2014-03-19 21:05:49

标签: mule

使用Mule Studio

版本:3.5.0 Build Id:201402101410

我有一个非常简单的流程。我需要从一个ftp服务器中获取一个文件并将其传输到另一个ftp服务器。当文件写入目标时,文件名看起来像某种UUId而不是原始文件名。如何获取文件名?我尝试了#[header:originalFilename]但是抛出了一个错误,所以我假设它可能只适用于文件连接器。这是我的流程:

    <?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]进行堆栈跟踪:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 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)
********************************************************************************

1 个答案:

答案 0 :(得分:1)

使用MEL:#[message.inboundProperties.originalFilename]。

我认为范围是问题。

在3.4 - http://www.mulesoft.org/documentation/display/current/Mule+ESB+3.4.0+Release+Notes

中对此进行了更改

Mule 3.4+ originalFilename位于入站范围内。所以使用:#[message.inboundProperties.originalFilename]

骡子&lt; 3.4 originalFilename在出站范围内。所以使用:#[message.outboundProperties.originalFilename]

问题记录在此处:https://www.mulesoft.org/jira/browse/MULE-6743