Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to concatenate 2 values in mule?

Tags:

mule

Can someone please let me know how to concatenate multiple values in mule?

Something like,

#[payload.getPayload()].concat(#[getSubject()])
like image 455
Learner Avatar asked Feb 25 '13 20:02

Learner


People also ask

How do I concatenate two strings in a Mule?

In DataWeave 2.0, concatenation can be achieved by using the ++ (plus plus) function. However, there are two additional syntax options to concatenate objects and one to concatenate strings in DataWeave. Concatenation is when you link two strings, objects, data types etc together in a chain or series.

How do you add two values in Mule 4?

In Mule 4, you can easily do this with DataWeave (using the Transform Message component). Just add multiple targets and select "Variable" as output.

How do you comment multiple lines in DataWeave?

We don't have the feature to comment multiple lines in Dataweave, but we can comment single line by using `//` operator.


1 Answers

I assume you are using Mule 3.3.x or above. If so you can use Mule Expression Language(MEL).

One example using MEL is:

#['Hello' + 'World']

Or MEL also allows you to use standard Java method invocation:

#[message.payload.concat(' Another String')]

Cheat sheet on MEL

MULE 4 Update

For Mule 4. Dataweave 2.0 is the main expression language:

Simple concat:

#['Hello' ++ ' World']
like image 68
Ryan Carter Avatar answered Sep 25 '22 04:09

Ryan Carter