Package org.mule.api

Examples of org.mule.api.MuleMessageCollection


        MuleMessage msg = event.getMessage();

        List<Object> payload = new ArrayList<Object>();
        if (msg instanceof MuleMessageCollection)
        {
            MuleMessageCollection collection = (MuleMessageCollection) msg;
            collection.getPayload();
            for (MuleMessage child : collection.getMessagesAsArray())
            {
                Object childPayload = child.getPayload();
                if (childPayload instanceof Collection)
                {
                    payload.addAll((Collection) childPayload);
View Full Code Here


    }

    @Test
    public void testMuleMessageCollectionPayload() throws Exception
    {
        MuleMessageCollection msgCollection = new DefaultMessageCollection(muleContext);
        MuleMessage msg = new DefaultMuleMessage("bar", muleContext);
        msgCollection.addMessage(msg);
        msg = new DefaultMuleMessage("zip", muleContext);
        msgCollection.addMessage(msg);
        simpleForeach.process(getTestEvent(msgCollection));

        assertSimpleProcessedMessages();
    }
View Full Code Here

    }

    @Test
    public void testNestedMuleMessageCollectionPayload() throws Exception
    {
        MuleMessageCollection parentCollection = new DefaultMessageCollection(muleContext);
        MuleMessageCollection childCollection1 = new DefaultMessageCollection(muleContext);
        MuleMessageCollection childCollection2 = new DefaultMessageCollection(muleContext);
        MuleMessage msg;
        msg = new DefaultMuleMessage("a1", muleContext);
        childCollection1.addMessage(msg);
        msg = new DefaultMuleMessage("a2", muleContext);
        childCollection1.addMessage(msg);
        msg = new DefaultMuleMessage("a3", muleContext);
        childCollection1.addMessage(msg);

        msg = new DefaultMuleMessage("b1", muleContext);
        childCollection2.addMessage(msg);
        msg = new DefaultMuleMessage("b2", muleContext);
        childCollection2.addMessage(msg);
        msg = new DefaultMuleMessage("c1", muleContext);
        childCollection2.addMessage(msg);

        parentCollection.addMessage(childCollection1);
        parentCollection.addMessage(childCollection2);

        nestedForeach.process(getTestEvent(parentCollection));
View Full Code Here

        MuleEvent event1 = new DefaultMuleEvent(message1, endpoint, flow);

        MuleMessage message2 = new DefaultMuleMessage("test event B", muleContext);
        MuleMessage message3 = new DefaultMuleMessage("test event C", muleContext);

        MuleMessageCollection messageCollection = new DefaultMessageCollection(
            mock(MuleContext.class));
        messageCollection.setInvocationProperty("key2", "value2");
        messageCollection.addMessage(message2);
        messageCollection.addMessage(message3);
        MuleEvent event2 = new DefaultMuleEvent(messageCollection, endpoint, flow);

        MuleEvent result = resultsHandler.aggregateResults(Collections.<MuleEvent> singletonList(event2),
            event1, mock(MuleContext.class));
        assertSame(event2, result);
View Full Code Here

        MuleMessage message2 = new DefaultMuleMessage("test event B", muleContext);
        MuleMessage message3 = new DefaultMuleMessage("test event C", muleContext);
        MuleMessage message4 = new DefaultMuleMessage("test event D", muleContext);
        MuleMessage message5 = new DefaultMuleMessage("test event E", muleContext);

        MuleMessageCollection messageCollection = new DefaultMessageCollection(
            mock(MuleContext.class));
        messageCollection.setInvocationProperty("key2", "value2");
        messageCollection.addMessage(message2);
        messageCollection.addMessage(message3);
        MuleEvent event2 = new DefaultMuleEvent(messageCollection, endpoint, flow);

        MuleMessageCollection messageCollection2 = new DefaultMessageCollection(
            mock(MuleContext.class));
        messageCollection.setInvocationProperty("key3", "value3");
        messageCollection.addMessage(message4);
        messageCollection.addMessage(message5);
        MuleEvent event3 = new DefaultMuleEvent(messageCollection2, endpoint, flow);
View Full Code Here

        MuleMessage message1 = new DefaultMuleMessage("test event A", muleContext);
        MuleMessage message2 = new DefaultMuleMessage("test event B", muleContext);
        MuleMessage message3 = new DefaultMuleMessage("test event C", muleContext);
        MuleMessage message4 = new DefaultMuleMessage("test event D", muleContext);
        MuleMessageCollection messageCollection1 = new DefaultMessageCollection(muleContext);
        MuleMessageCollection messageCollection2 = new DefaultMessageCollection(muleContext);
        messageCollection1.addMessage(message1);
        messageCollection1.addMessage(message2);
        messageCollection2.addMessage(message3);
        messageCollection2.addMessage(message4);

        messageCollection1.setCorrelationGroupSize(2);
        messageCollection1.setCorrelationId(messageCollection1.getUniqueId());
        messageCollection2.setCorrelationGroupSize(2);
        messageCollection2.setCorrelationId(messageCollection1.getUniqueId());

        InboundEndpoint endpoint = MuleTestUtils.getTestInboundEndpoint(MessageExchangePattern.ONE_WAY,
            muleContext);
        MuleEvent event1 = new DefaultMuleEvent(messageCollection1, endpoint, testService);
        MuleEvent event2 = new DefaultMuleEvent(messageCollection2, endpoint, testService);
View Full Code Here

        }
    }

    private MuleEvent createMessageCollectionWithSingleMessage(MuleEvent event, MuleContext muleContext)
    {
        MuleMessageCollection coll = new DefaultMessageCollection(muleContext);
        coll.addMessage(event.getMessage());
        event.setMessage(coll);
        return OptimizedRequestContext.unsafeSetEvent(event);
    }
View Full Code Here

    private MuleEvent createMessageCollection(final List<MuleEvent> nonNullResults,
                                              final MuleEvent previous,
                                              MuleContext muleContext)
    {
        MuleMessageCollection coll = new DefaultMessageCollection(muleContext);
        for (MuleEvent event : nonNullResults)
        {
            coll.addMessage(event.getMessage());
        }
        coll.propagateRootId(previous.getMessage());
        MuleEvent resultEvent = new DefaultMuleEvent(coll, previous, previous.getSession());
        for (String name : previous.getFlowVariableNames())
        {
            resultEvent.setFlowVariable(name, previous.getFlowVariable(name));
        }
View Full Code Here

    }

    private MuleEvent runFlowAndAssertResponse(Flow flow, MuleEvent event, String... letters) throws Exception
    {
        MuleEvent resultEvent = flow.process(event);
        MuleMessageCollection messageCollection = (MuleMessageCollection) resultEvent.getMessage();
        for (int i = 0; i < letters.length; i++)
        {
            MuleMessage message = messageCollection.getMessage(i);
            assertThat(message.getPayloadAsString(), is(letters[i]));
        }
        return resultEvent;
    }
View Full Code Here

        MuleClient client = muleContext.getClient();
        MuleMessage result = client.send("vm://distributor.queue", fruitBowl, null);

        assertNotNull(result);
        assertTrue(result instanceof MuleMessageCollection);
        MuleMessageCollection coll = (MuleMessageCollection) result;
        assertEquals(3, coll.size());
        List<?> results = (List<?>) coll.getPayload();

        assertTrue(results.contains("Apple Received"));
        assertTrue(results.contains("Banana Received"));
        assertTrue(results.contains("Orange Received"));
    }
View Full Code Here

TOP

Related Classes of org.mule.api.MuleMessageCollection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.