Pergunta

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.

Foi útil?

Solução

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...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top