Is there a way to pass payload into java class in Mule 4.3? Can we pass payload as a parameter into a java function?
Yes, you can use the Java Module to invoke a method in a Java class . You can use the payload and variables as arguments.
Example (from above docs):
<java:new class="com.me.TaxCalculator"
constructor="TaxCalculator()"
target="taxCalculator"/>
<java:invoke instance="#[vars.taxCalculator]"
class="com.me.TaxCalculator"
method="calculateTax(Double, Integer)"
target="totalTax">
<java:args>#[{
price: 25.5,
percentAdditionalTax: 2
}]</java:args>
</java:invoke>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.