简体   繁体   English

Mule-如何获取在出站端点中创建的文件的名称

[英]Mule - how to get the name of the file created in an outbound endpoint

I have a Mule application that is writing a file in an outbound endpoint, with the config below: 我有一个Mule应用程序,该应用程序在出站端点中写入文件,其配置如下:

<file:outbound-endpoint path="${Outbound}" outputPattern="outputFile_#[function:datestamp:yyyyMMddHHmmss].csv" doc:name="Output File"/>

Following this point in the flow I need to display a log message along the lines of "Successfully created file {filename}". 在流程中的这一点之后,我需要在“成功创建文件{filename}”行中显示一条日志消息。

The issue I'm having is that I can't find a way of displaying the name of the file I have just created. 我遇到的问题是我找不到显示刚创建的文件名的方法。 I could put: Successfully created file outputFile_#[function:datestamp:yyyyMMddHHmmss].csv , but there is a chance that the datestamp may differ by one second. 我可以放: Successfully created file outputFile_#[function:datestamp:yyyyMMddHHmmss].csv ,但是datestamp可能相差一秒钟。

Is there a way in Mule that I can display the name of the file I've just written? Mule中有什么方法可以显示我刚刚编写的文件的名称?

UPDATE UPDATE

Following the response from @til_b, I've achieved this using the following: 遵循@til_b的响应,我已经使用以下方法实现了这一点:

<set-variable value="outputFile_#[function:datestamp:yyyyMMddHHmmss].csv" variableName="Filename" doc:name="Variable"/>
<file:outbound-endpoint path="${Outbound}" outputPattern="#[variable:Filename]" doc:name="Output File"/>
<logger level="INFO" message="Successfully created file #[variable:Filename]" doc:name="Logger" />

I dont know about mule, but when i encounter such a problem while programming i store the generated filename in a variable, and then use that variable to actually create the file and display the message. 我不了解m子,但是当我在编程时遇到这样的问题时,我将生成的文件名存储在一个变量中,然后使用该变量实际创建文件并显示消息。

In Pseudocode: 在伪代码中:

var filename = #yyyymmddhhMMss.csv
create_file(filename)
log_message(filename + ' successfully created')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM