Mule string message split and aggreate

268 Views Asked by At

My requirement is accept a endpoint like localhost:8080/book/{id}/detail?name=whatever; then get the path param'id' and query param 'name'; then split message to create two requests like xxx1/id and xxx2/name; then aggregate the two responses together.

My initial idea is to use string like "id,name" then split to id and name for each request. I see many mule concepts splitter,router,vm,aggregator.. Can you please lighten me an solution to implement this ? What mule component I should use and what kind of customize java code Ineed to write.

1

There are 1 best solutions below

2
On

The easiest way you can do is to get the value from your path param id and query param name.
If you are using Mule 3.6 or above version, you can get both the values using MEL, something like #[message.inboundProperties.'http.uri.params'.id] and #[message.inboundProperties.'http.query.params'.name]
reference :- https://developer.mulesoft.com/docs/display/current/HTTP+Listener+Connector

Once you get the values, you can easily create the String you want.
For aggregating the response, you can either use Mule's available aggregator or can create your own custom aggregator using Java class