Package org.mule

Examples of org.mule.DefaultMessageCollection


        return toMessageCollection(true);
    }

    public MuleMessageCollection toMessageCollection(boolean sortByArrival) throws ObjectStoreException
    {
        DefaultMessageCollection col = new DefaultMessageCollection(muleContext);
        List<MuleMessage> messages = new ArrayList<MuleMessage>();

        synchronized (events)
        {
            for (Serializable id : events.allKeys())
            {
                MuleMessage message = events.retrieve(id).getMessage();
                messages.add(message);
            }
        }

        if (sortByArrival)
        {
            Collections.sort(messages, new ArrivalOrderMessageComparator());
        }
        col.addMessages(messages);
        return col;
    }
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

    }

    @Test
    public void testMessageCollectionConfiguration() throws Exception
    {
        MuleMessageCollection msgCollection = new DefaultMessageCollection(muleContext);
        for (int i = 0; i < 10; i++)
        {
            MuleMessage msg = new DefaultMuleMessage("message-" + i, muleContext);
            msg.setProperty("out", "out" + (i+1), PropertyScope.OUTBOUND);
            msgCollection.addMessage(msg);
        }

        MuleMessage result = client.send("vm://input-7", msgCollection);
        assertEquals(10, result.getInboundProperty("totalMessages"));
        assertEquals(msgCollection.getPayload(), result.getPayload());
        FlowAssert.verify("message-collection-config");
    }
View Full Code Here

    }

    @Test
    public void testMessageCollectionConfigurationOneWay() throws Exception
    {
        MuleMessageCollection msgCollection = new DefaultMessageCollection(muleContext);
        for (int i = 0; i < 10; i++)
        {
            MuleMessage msg = new DefaultMuleMessage("message-" + i, muleContext);
            msg.setProperty("out", "out" + (i+1), PropertyScope.OUTBOUND);
            msgCollection.addMessage(msg);
        }

        client.dispatch("vm://input-71", msgCollection);
        FlowAssert.verify("message-collection-config-one-way");
    }
View Full Code Here

TOP

Related Classes of org.mule.DefaultMessageCollection

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.