0
votes

I have an inbound org.mule.api.MuleMessage with a huge payload. Payload needs to be split based on some logic. With split payloads I'm forming list of org.mule.api.MuleMessage, where in each message has same headers but different payload. I need to send each message from the list as a separate message in outbound queue.
I am using <collection-splitter>, but it gives me following error :

org.mule.api.transformer.TransformerMessagingException: Invalid type passed to StreamMessage: DefaultMuleMessage . Allowed types are: Boolean Byte Short Character Integer Long Float DoubleString and byte[] (javax.jms.MessageFormatException) (org.mule.api.transformer.TransformerException). Message payload is of type: ArrayList

I'm using following configuration :

    <flow name="Inbound flow">
     <inbound-endpoint ref="In" />
     <pooled-component>     
        <spring-object bean="inboundAdapterProcessor" />
        <pooling-profile initialisationPolicy="INITIALISE_ALL" maxActive="${component.maxActive}" />
     </pooled-component>
     <collection-splitter enableCorrelation="IF_NOT_SET" />
     <outbound-endpoint ref="Out"/> 
    </flow>

"In" and "Out" are nothing but jms queue endpoints.

Java Code :

     public Object onCall(MuleEventContext eventContext) throws Exception {
        List<MuleMessage> messages = new ArrayList<MuleMessage>();
        MuleMessage message = eventContext.getMessage();
        String payload = message.getPayloadAsString();
        //split the payload based on some logic
        String[] payloads = getSplitPayload(payload);
        int i= 0;
        while(i<payloads.lenght){
        //create DefaultMuleMessage here
        MuleMessage  splitMessage = new DefaultMuleMessage(/*passing appropriate params here*/);
        //set the same headers
        //set the payload
        splitMessage.setPaylod(payloads[i]);
        messages.add(splitMessage);
        }
        return messages;
     }

Kindly advise. Your help is much appreciated.Thanks in advance.

1
Please add your stacktrace.BetaRide
I have already added the stacktrace aboveAniket Divekar

1 Answers

2
votes

<object-to-byte-array-transformer /> will make any serializable object able to be sent over JMS - don't forget to transform it back with <byte-array-to-object-transformer /> when you receive it.