连接文件的文件名和时间 Name/pattern Mule 3

concatenate file name and time for the file Name/pattern Mule 3

我正在尝试将文件连接器内的文件名和日期时间连接起来作为输出文件的名称。我收到语法错误。这是因为 MEL 表达式已经出现在配置文件中的双引号中,所以我必须用单引号或 \u0027expression\u0027 或“(”表达式”)转义双引号。它们中的 none 如何工作。

输出文件应具有以下模式: 文件名-2020-02-09T12:08:53Z.json

我试过这个函数,只是转义引号会出错

apples-#[server.dateTime.format("yyyy-MM-dd'T'HH:mm:ss'Z'")].json

我得到的错误是这样的;

      "changenr...
Element               : /ref-sys-api-main/processors/5/ref-sys-api/subprocessors/5 @ ref-sys-api.xml:85 (write-file-service)
Element XML           : <file:outbound-endpoint path="G:\Local" outputPattern="apples-#[server.dateTime.format("yyyy-MM-dd'T'HH:mm:ss'Z'")].json" responseTimeout="10000" doc:name="write-file-service"></file:outbound-endpoint>
--------------------------------------------------------------------------------
Root Exception stack trace:
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
    at java.io.WinNTFileSystem.canonicalize0(Native Method)
    at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428)
    at java.io.File.getCanonicalPath(File.java:618)
    at java.io.File.getCanonicalFile(File.java:643)
    at org.mule.util.FileUtils.newFile(FileUtils.java:369)
    at org.mule.util.FileUtils.createFile(FileUtils.java:95)
    at org.mule.transport.file.FileConnector.getOutputStream(FileConnector.java:561)
    at org.mule.transport.file.FileMessageDispatcher.doDispatch(FileMessageDispatcher.java:55)
    at org.mule.transport.AbstractMessageDispatcher.process(AbstractMessageDispatcher.java:109)
    at org.mule.transport.AbstractConnector$DispatcherMessageProcessor.process(AbstractConnector.java:2735)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:111)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
    at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
    at org.mule.interceptor.AbstractEnvelopeInterceptor.processBlocking(AbstractEnvelopeInterceptor.java:59)
    at org.mule.processor.AbstractRequestResponseMessageProcessor.process(AbstractRequestResponseMessageProcessor.java:48)
    at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:131)
    at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.process(AsyncInterceptingMessageProcessor.java:221)
    at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.process(AsyncInterceptingMessageProcessor.java:214)
    at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
    at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:35)
    at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:22)
    at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
    at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
    at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:67)
    at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
    at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
    at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
    at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
    at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
    at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
    at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
    at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:110)
    at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:30)
    at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:213)
    at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:53)
    at org.mule.work.WorkerContext.run(WorkerContext.java:301)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

********************************************************************************

INFO  2022-02-14 14:54:37,161 [[ref-sys-api-1].connector.file.mule.default.dispatcher.01] org.mule.api.processor.LoggerMessageProcessor: Error: 
********************************************************************************
Message               : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=file:///C:/Local/, connector=FileConnector


********************************************************************************
 Response error: IOException: The filename, directory name, or volume label syntax is incorrect

谢谢

异常中的错误消息说明了这不起作用的原因:

java.io.IOException: The filename, directory name, or volume label syntax is incorrect
    at java.io.WinNTFileSystem.canonicalize0(Native Method)

该错误与表达式的语法无关。它不是来自 Mule,而是来自 Windows。 Windows 中不能有带冒号 (´:´) 的文件名。在其他操作系统中可能可行,但不值得。只需使用一些不同的字符作为时间分隔符,或者完全使用 none。