I am creating a process using Mule 3.4.1 which after processing a file it writes out the file with a specific filename. The input filename is: MMDDYYYY_sys_newhires.csv The processed filename is: MMDDYYYY_sys_newhires_NNN.csv

The code that i am using is below:

#[filename = message.inboundProperties.originalFilename;
  filename= com.cfa.apps.icims.mule.CounterSingleton.getInstance().getCount() 
         +  filename.substring(0,filename.length() -1 -4) + ".csv";
  filename]

The problem exists in the first line. message.inboundProperties.originalFilename.

I have tried a number of different combinations

message.inboundProperties.originalFilename
message.inboundProperties['originalFilename']
message.inboundProperties.originalFileName
message.inboundProperties['originalFileName']
message.inboundProperties.sourceFilename
message.inboundProperties['sourceFilename']
message.inboundProperties.sourceFileName
message.inboundProperties['sourceFileName']

Now I have also tried nesting the #[header:originalFilename], this works by itself, but you can't nest the expression within the code at least as far as I know.

Any help?

UPDATE: I am using the inbound file transport

有帮助吗?

解决方案

Since you don't show the endpoint configuration, I'm going to assume that this is happening with a file inbound endpoint.

For a reason that goes beyond imagination, the file message receiver behind the inbound endpoint puts the originalFilename property in the outbound scope when evaluating the expression to generate the archived file name.

So use: message.outboundProperties.originalFilename

其他提示

I have tested this mel EXPRESSION in ESB 3.7.1 and it is working fine!!

message.inboundProperties.originalFilename=='firstfile.txt'
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top