Package org.mule.api

Examples of org.mule.api.MuleEvent


    @Override
    protected List<MuleMessage> getMessages() throws Exception
    {
        if (isReceiveMessagesInTransaction())
        {
            MuleEvent message = getFirstMessage();
            if (message == null)
            {
                return null;
            }
           
            List<MuleMessage> messages = new ArrayList<MuleMessage>(1);
            messages.add(message.getMessage());
            return messages;
        }
        else
        {
            return getFirstMessages();
View Full Code Here


        List<MuleMessage> messages = new LinkedList<MuleMessage>();

        int batchSize = getBatchSize(queue.size());

        // try to get the first event off the queue
        MuleEvent message = (MuleEvent) queue.poll(connector.getQueueTimeout());

        if (message != null)
        {
            // keep first dequeued event
            messages.add(message.getMessage());

            // keep batching if more events are available
            for (int i = 0; i < batchSize && message != null; i++)
            {
                message = (MuleEvent)queue.poll(0);
                if (message != null)
                {
                    messages.add(message.getMessage());
                }
            }
        }

        // let our workManager handle the batch of events
View Full Code Here

            {
                postMethod.setRequestEntity(new ByteArrayRequestEntity((byte[]) src, outboundMimeType));
            }
            else if (src instanceof OutputHandler)
            {
                final MuleEvent event = RequestContext.getEvent();
                postMethod.setRequestEntity(new StreamPayloadRequestEntity((OutputHandler) src, event));
            }
            else
            {
                final byte[] buffer = SerializationUtils.serialize((Serializable) src);
View Full Code Here

            // for MULE_USER header. Filter out other headers like "soapMethods" and
            // MuleProperties.MULE_METHOD_PROPERTY and "soapAction"
            // and also filter out any http related header
            messageToRoute.addProperties(AxisCleanAndAddProperties.cleanAndAdd(RequestContext.getEventContext()));

            MuleEvent event = receiver.routeMessage(messageToRoute);
            MuleMessage message = event == null ? null : event.getMessage();

            if (message != null)
            {
                ExceptionPayload wsException = message.getExceptionPayload();
View Full Code Here

                }
                return null;
            }
            else
            {
                MuleEvent event = null;
                if (logger.isDebugEnabled())
                {
                    logger.debug("Waiting for a message on " + endpoint.getEndpointURI().getAddress());
                }
                try
                {
                    event = (MuleEvent) queue.poll(timeout);
                }
                catch (InterruptedException e)
                {
                    logger.error("Failed to receive message from queue: " + endpoint.getEndpointURI());
                }
                if (event != null)
                {
                    //The message will contain old thread information, we need to reset it
                    if(event.getMessage() instanceof ThreadSafeAccess)
                    {
                        ((ThreadSafeAccess) event.getMessage()).resetAccessControl();
                    }
                    if (logger.isDebugEnabled())
                    {
                        logger.debug("Message received: " + event);
                    }
                    return event.getMessage();
                }
                else
                {
                    if (logger.isDebugEnabled())
                    {
View Full Code Here

        message2.setCorrelationId(message1.getUniqueId());
        message3.setCorrelationId(message1.getUniqueId());
        message1.setCorrelationGroupSize(3);

        InboundEndpoint endpoint = MuleTestUtils.getTestInboundEndpoint(MessageExchangePattern.ONE_WAY, muleContext);
        MuleEvent event1 = new DefaultMuleEvent(message1, endpoint, session);
        MuleEvent event2 = new DefaultMuleEvent(message2, endpoint, session);
        MuleEvent event3 = new DefaultMuleEvent(message3, endpoint, session);

        assertNull(router.process(event1));
        assertNull(router.process(event2));
        MuleEvent resultEvent = router.process(event3);
        assertNotNull(resultEvent);
        MuleMessage resultMessage = resultEvent.getMessage();
        assertNotNull(resultMessage);
        List<String> payload = (List<String>)resultMessage.getPayload();
        assertEquals(3, payload.size());
        assertEquals("test event A", payload.get(0));
        assertEquals("test event B", payload.get(1));
View Full Code Here

    public void testArrayArg() throws MuleException, Exception
    {
        invoker.setMethodName("testArrayArg");
        invoker.setArguments(Collections.singletonList(new String[]{"#[string:1]", "#[string:2]"}));
        invoker.initialise();
        MuleEvent result = invoker.process(getTestEvent(""));
        assertEquals(String[].class, result.getMessage().getPayload().getClass());
        assertEquals("1", ((String[]) result.getMessage().getPayload())[0]);
        assertEquals("2", ((String[]) result.getMessage().getPayload())[1]);
    }
View Full Code Here

    public void testListArg() throws MuleException, Exception
    {
        invoker.setMethodName("testListArg");
        invoker.setArguments(Collections.singletonList(Collections.singletonList("#[string:1]")));
        invoker.initialise();
        MuleEvent result = invoker.process(getTestEvent(""));
        assertTrue(List.class.isAssignableFrom(result.getMessage().getPayload().getClass()));
        assertEquals("1", ((List) result.getMessage().getPayload()).get(0));
    }
View Full Code Here

    protected abstract EventCorrelatorCallback getCorrelatorCallback(MuleContext muleContext);

    public MuleEvent process(MuleEvent event) throws MuleException
    {
        MuleEvent result = eventCorrelator.process(event);
        if (result == null)
        {
            return null;
        }
        return processNext(result);
View Full Code Here

    {
        invoker.setMethodName("testListArg");
        invoker.setArguments(Collections.singletonList(Collections.singletonList(Collections.singletonMap(
            "#[string:key]", "#[string:val]"))));
        invoker.initialise();
        MuleEvent result = invoker.process(getTestEvent(""));
        assertTrue(List.class.isAssignableFrom(result.getMessage().getPayload().getClass()));
        assertEquals("val", ((Map) ((List) result.getMessage().getPayload()).get(0)).get("key"));
    }
View Full Code Here

TOP

Related Classes of org.mule.api.MuleEvent

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.