Help!! Mule Aggregator Issue

View: New views
2 Messages — Rating Filter:   Alert me  

Help!! Mule Aggregator Issue

by Murugra :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am new to Mule and trying to see how do I aggregate messages from two different services. I am able to test each of the two services successfully but when i try to do the aggregation of the messages, I get the following error.

These are two services that provide just firstname and lastname of a user.

ERROR 2007-12-01 19:22:55,312 [connector.http.0.receiver.4] org.mule.DefaultExceptionStrategy: Caught exception in Exception Strategy: java.util.ArrayList
java.lang.ClassCastException: java.util.ArrayList
        at org.mule.transport.http.HttpResponse.setBody(HttpResponse.java:288)
        at org.mule.transport.http.transformers.MuleMessageToHttpResponse.createResponse(MuleMessageToHttpResponse.java:297)
        at org.mule.transport.http.transformers.MuleMessageToHttpResponse.transform(MuleMessageToHttpResponse.java:100)
        at org.mule.transformer.AbstractMessageAwareTransformer.doTransform(AbstractMessageAwareTransformer.java:68)
        at org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:254)
        at org.mule.DefaultMuleMessage.applyAllTransformers(DefaultMuleMessage.java:621)
        at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:582)
        at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:575)
        at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:373)
        at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:252)
        at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:193)
        at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:273)
        at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:227)
        at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:190)
        at org.mule.work.WorkerContext.run(WorkerContext.java:310)
        at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
        at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:595)

Mule Configuration

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:http="http://www.mulesource.org/schema/mule/http/2.2"
        xmlns:https="http://www.mulesource.org/schema/mule/https/2.2"
        xmlns:soap="http://www.mulesource.org/schema/mule/soap/2.2" xmlns:cxf="http://www.mulesource.org/schema/mule/cxf/2.2"
        xmlns:tcp="http://www.mulesource.org/schema/mule/tcp/2.2" xmlns:xm="http://www.mulesource.org/schema/mule/xml/2.2"
        xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2"

        xsi:schemaLocation="
          http://www.mulesource.org/schema/mule/http/2.2 http://www.mulesource.org/schema/mule/http/2.2/mule-http.xsd
          http://www.mulesource.org/schema/mule/https/2.2 http://www.mulesource.org/schema/mule/https/2.2/mule-https.xsd
          http://www.mulesource.org/schema/mule/soap/2.2 http://www.mulesource.org/schema/mule/soap/2.2/mule-soap.xsd
          http://www.mulesource.org/schema/mule/cxf/2.2 http://www.mulesource.org/schema/mule/cxf/2.2/mule-cxf.xsd
          http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
          http://www.mulesource.org/schema/mule/tcp/2.2 http://www.mulesource.org/schema/mule/tcp/2.2/mule-tcp.xsd
          http://www.mulesource.org/schema/mule/xml/2.2 http://www.mulesource.org/schema/mule/xml/2.2/mule-xml.xsd
          http://www.mulesource.org/schema/mule/xml/2.2 http://www.mulesource.org/schema/mule/xml/2.2/mule-xml.xsd
          http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd">


        <xm:object-to-xml-transformer name="ObjectToXML" />

        <model name="ProfileAggregator">

                <!--  Aggregated Chain -->

                <!--  Working Chain -->
                <service name="SendAggregatedRequestService">
                        <inbound>
                                <http:inbound-endpoint
                                        address="http://localhost:8080/Profile/AggregatedConsumerProfileDetails"
                                        synchronous="true">
                                </http:inbound-endpoint>
                        </inbound>

                        <outbound>
                                <multicasting-router>
                                        <vm:outbound-endpoint path="ConsumerHttp"
                                                synchronous="true" />
                                        <vm:outbound-endpoint path="VideoHttp"
                                                synchronous="true" />

                                </multicasting-router>
                        </outbound>

                </service>



                <!--  End of Aggregated Chain -->


                <!--  Working Chain -->
                <service name="SendProfileRequestService">
                        <inbound>
                                <vm:inbound-endpoint path="ConsumerHttp"
                                        synchronous="true" />
                        </inbound>

                        <component class="com.philips.consumer.ConsumerProfileService" />
                        <outbound>
                                <chaining-router>
                                        <vm:outbound-endpoint path="ConsumerProfileOutput"
                                                synchronous="true" />

                                </chaining-router>
                        </outbound>

                </service>

                <service name="ConsumerProfileOutputService">
                        <inbound>
                                <vm:inbound-endpoint path="ConsumerProfileOutput"
                                        transformer-refs="ObjectToXML" synchronous="true" />
                        </inbound>
                        <outbound>
                                <chaining-router>
                                        <vm:outbound-endpoint path="aggregator.in"
                                                synchronous="true" />
                                </chaining-router>
                        </outbound>

                </service>

                <!-- Working Chain  -->
                <service name="SendVideoProfileRequestService">
                        <inbound>
                                <vm:inbound-endpoint path="VideoHttp"
                                        synchronous="true" />
                        </inbound>

                        <component class="com.philips.video.VideoProfileService" />
                        <outbound>
                                <chaining-router>
                                        <vm:outbound-endpoint path="VideoProfileOutput"
                                                synchronous="true" />

                                </chaining-router>
                        </outbound>

                </service>

                <service name="VideoProfileOutputService">
                        <inbound>
                                <vm:inbound-endpoint path="VideoProfileOutput"
                                        transformer-refs="ObjectToXML" synchronous="true" />
                        </inbound>

                        <outbound>
                                <chaining-router>
                                        <vm:outbound-endpoint path="aggregator.in"
                                                synchronous="true" />
                                </chaining-router>
                        </outbound>
                </service>

                <service name="aggregateService">
                        <inbound>
                                <vm:inbound-endpoint path="aggregator.in" />
                                <collection-aggregator-router />
                        </inbound>
                </service>



        </model>
</mule>


Re: Help!! Mule Aggregator Issue

by Richard Swart :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You are using a multicasting router with synchronous outbound endpoints. This means that each endpoint processes the original message sequentially, and the results are collected into a single reply: a List of MuleMessages. This List is then returned to the http:inbound-endpoint, which tries to transform the result to an HttpResponse. This is not allowed.

You first need to transform the aggregated result. One way to do this is to add a responseTransformer to the inbound endpoint:

<service name="SendAggregatedRequestService">
<inbound>
<http:inbound-endpoint
address="http://localhost:8080/Profile/AggregatedConsumerProfileDetails"
synchronous="true" responseTransformer-refs="myCustomerTransformer">
</http:inbound-endpoint>
</inbound>

<outbound>
<multicasting-router>
<vm:outbound-endpoint path="ConsumerHttp"
synchronous="true" />
<vm:outbound-endpoint path="VideoHttp"
synchronous="true" />

</multicasting-router>
</outbound>

</service>

HTH

Regards,
Mario

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email