Search code examples
javaantpropertiesmulemule-el

Accessing properties set at runtime using property ${} notation in Mule flow


In a Mule flow, I have a property set in my flow as follows:

    <set-property propertyName="certPath" value="/tmp/#[aVariable]/certificate.pem" doc:name="Property"/>

I'm now trying to use it inside my sftp outbound-endpoint identityFile attribute, as follows: identityFile="${certPath}"

This does not work and takes in the placeholder as a string (as is.)

Am I missing something in the way properties should be set and then accessed?

I have also tried to add a message property in the session scope, but then when trying ${session.certPath} nothing gets evaled either.


Solution

  • In order to access property set during a flow you need to use the Mule Expression language.

    Try using the following to access your property.

    #[message.outboundProperties['certPath']]
    

    Note: This works only when the property is accessed in the same flow.

    The ant style access ${session.certPath} is for loading properties from properties file.

    Refer the following link for more details on MEL.

    http://www.mulesoft.org/documentation/display/current/Property+Transformer+Reference

    Hope this helps.