I'm trying to concatenate the filename and dateTime inside the file connector as name for the output file. I get a syntax error. This because MEL expressions already appear enclosed in double quotes in configuration files, so I have to escape the double quotes with single quotes or \u0027expression\u0027 or "("expression"). How ever none of them works.
The output file should have the following pattern: filename-2020-02-09T12:08:53Z.json
I have tried with this function, only escaping the quotes gives an error
apples-#[server.dateTime.format("yyyy-MM-dd'T'HH:mm:ss'Z'")].json
The error I get is this;
"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$1.process(AsyncInterceptingMessageProcessor.java:221)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.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
Thanks
The error message in the exception is telling the reason this doesn't work:
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
The error is not related to the syntax of the expression. It is not coming from Mule but from Windows. You can not have a file name with colons (´:´) in Windows. It may be possible in other Operating Systems but it is not worth it. Just use some different character as a time separator, or none at all.