Mule originalFilename is null

2019-07-20 03:09发布

问题:

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

回答1:

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



回答2:

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

message.inboundProperties.originalFilename=='firstfile.txt'