Take the 2-minute tour ×

The story so far

I have a SOAP service that sends its response (say Response_A) to an <all> flow. Inside the flow, there are three SOAP services (say B, C and D) that take inputs from Response_A. I am taking fields from Response_A and using XSLT, I can formulate requests for B, C and D.

Quick question: I am using <async> blocks inside <all> to process messages in parallel. The processing was not parallel when using <all> and <processor-chain> tags inside it. Any ideas why?

The roadmap

I will read the responses from all three B, C and D and combine them into a single response (probably using XSLT again) and send it to E.

The roadblock

After coming out of the <all> flow, I get a MuleMessageCollection. How to read it, and combine the messages into a single message?

My attempts

I tried aggregating the messages based on a correlation ID but I noticed that a correlation id is present only when the message from A was split by the <all> tag and was being sent to B, C and D. The correlation ID vanishes in the SOAP envelope that comes as a response from these services, even if I turned enableMuleSoapHeaders to true. I cannot modify the services. So, how do I make the correlation id appear on the SOAP response (provided a correlation id is absolutely necessary if I want to merge messages)

I will also need the group size to aggregate messages, I guess.

I even tried adding a correlation id using message property transformer, but it did not work that way. I was stuck with a MessageCollection and did not know how to read it, even though there were probably messages with correlation id's inside it.

So, it boils down to one question. What are the ways to merge messages from a MessageCollection?

I want to do this in xml, without writing a custom transformer in Java. Is it possible? What should be my approach?

Note: The response messages from B, C and D have different DOMs structures. The merged message that I want to create has a different DO from all of A, B, C and D's responses and requests.

If it helps, I a trying to work on a similar situation as described here: http://ricston.com/blog/?p=640 only difference is, I am using flows and the all tag.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The processing was not parallel when using and tags inside it. Any ideas why?

This is because all and processor-chain are synchronous by nature: they do not parallelize anything.

Now for your problem of aggregating remote asynchronous responses, if the remote service doesn't reflect back the Mule headers (which is the case for the vast majority of non-Mule powered service), you need to find out if you can use maybe a value inside the response payload that would be reflected back from the remote service (that could be a SOAP header or a field, like an ID, inside the SOAP body). If that is the case, you can configure the collection-aggregator with a expression-message-info-mapping that specifies that correlation will not be done using the Mule header but another source.

Otherwise, you'd rather keep the all block and make the calls one after the other...

share|improve this answer
Thanks David. You are my savior. :) So, do you have any ideas on accumulating messages in a Message Collection? I am getting an object of a CopyOnWriteArrayList that holds both the XML responses that I need to combine into one. I could see it on the tc server console, when I tried sending it as input to the next server. So, how do I aggregate messages present in a CopyOnWriteArrayList and send it as an XML to the next service? With this last step, my planned flow will be complete. –  r3st0r3 Apr 19 '12 at 19:33
A CopyOnWriteArrayList is actually just a java.util.List. This list contains whatever came back from the remote calls (either Strings or byte[] or InputStream, check it out). So all you need is to create a transformer that assembles these payloads. It seems you want them as an XML entity, so an option is to assemble them below a new root (say <remote-responses>) and pass that to your response builder component. –  David Dossot Apr 19 '12 at 20:13
I got it. I added an object to XML transformer after the CopyOnWritArrayList and wrote a custom transformer in Java. I wanted to do it using XSLT but I do not know XSLT too well. –  r3st0r3 Apr 25 '12 at 5:32

Your Answer


