Using WSO2 Enrich mediator
Assume we need to copy a whole message context to a property for further use. As an example, if we use Amazon SQS Connector, we may need that message to send it to a Queue as the message body, but we need to pass it as a property. How can we achieve this?
Let’s assume that we are building a message which needs to be passed to the SimpleStockQuote. The request simply follows like this.
Thinking from the ease of the user, we do not want the user to send this message as the input. Therefore we ask from the user only the value for the symbol parameter.
Therefore, user input would be as follow.
Using this we are going to build the message as convert the whole message context as a property.
We can use a sequence as below.
First, we will copy the user input to a property called companyName. It is used in args as the first argument. The message is build using that as $1.
Then we use enrich mediator to copy the whole message body a property called target_property.
As I explained this can be used anywhere we want as an example, for AmazonSQS Connector, message body as shown below.