Using p() function in Transform Message in Mule Plugin

Viewed 1159

I have a mule plugin added as a dependency in my Project-A, In the mule-plugin I have defined a Transform Message where I am referring the values from the properties file defined in the plugin using p('property_name'). But it is throwing an error. Is it possible to define p() in the mule plugin and add the mule plugin as a dependency in a Project and expect it to work fine. If not is there any work around for it?

3 Answers

You can try the following dataweave construct to retrieve a property value in transformations:

%dw 2.0
output application/java
---
{
  myPropValue: Mule::p("my.property.name")
}

Instead of using the property inside the Transform (DataWeave) operation, set a variable to the property before calling the transformation, using the property placeholder syntax (ie "${property.name}").

Even if that works, you should reconsider the design of the application. Using properties defined in the plugin could conflict with the application defined properties.

Funny thing - even Mule is kinda "interpretation" approach - it does it statically as soon as it process stuff.

Look at your logs how application is loaded and instantiated - you will see modules and flows and plugins loaded in some sequence. Mostly it is based on the alphabetical order of the Mule modules.

If module A uses properies which are defined inside module B - it will be null becuase when A is loaded B does not exist yet and so there are no properies at all.

In short - look to log as modules laded and rename the XML files if order is not right for you.

https://simpleflatservice.com/mule4/Properties.html

Related