Package org.mule.api

Examples of org.mule.api.MuleEvent


    public void testEventMetaDataPropagation() throws MuleException
    {
        Service service = muleContext.getRegistry().lookupService("component1");
        MuleSession session = new DefaultMuleSession(service, muleContext);
        MuleEvent event = new DefaultMuleEvent(new DefaultMuleMessage("Test MuleEvent", muleContext),
            ((ServiceCompositeMessageSource) service.getMessageSource()).getEndpoints().get(0), session);
        service.sendEvent(event);
    }
View Full Code Here


    public void testResponseEventsCleanedUp() throws Exception
    {
        RelaxedAsyncReplyMP mp = new RelaxedAsyncReplyMP();
       
        MuleEvent event = getTestEvent("message1");
        final MuleMessage message = event.getMessage();
        final String id = message.getUniqueId();
        message.setCorrelationId(id);
        message.setCorrelationGroupSize(1);
       
        SensingNullMessageProcessor listener = getSensingNullMessageProcessor();
View Full Code Here

        TestEndpointMessageNotificationListener listener = new TestEndpointMessageNotificationListener();
        muleContext.registerListener(listener);

        InboundEndpoint endpoint = createTestInboundEndpoint(null, null);
        MessageProcessor mp = new InboundNotificationMessageProcessor(endpoint);
        MuleEvent event = createTestInboundEvent(endpoint);
        mp.process(event);

        assertTrue(listener.latch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
        assertEquals(EndpointMessageNotification.MESSAGE_RECEIVED, listener.messageNotification.getAction());
        assertEquals(endpoint.getEndpointURI().getUri().toString(),
            listener.messageNotification.getEndpoint());
        assertTrue(listener.messageNotification.getSource() instanceof MuleMessage);
        assertEquals(event.getMessage().getPayload(),
            ((MuleMessage) listener.messageNotification.getSource()).getPayload());
    }
View Full Code Here

    }
   
    @Override
    public MuleEvent handleException(Exception exception, MuleEvent event)
    {
        MuleEvent result = super.handleException(exception, event);
        result.getMessage().setPayload("Ka-boom!");
        return result;
    }
View Full Code Here

            endpoint, getTestSession(getTestService(), muleContext));
    }

    protected MuleEvent assertMessageSent(boolean sync) throws MuleException
    {
        MuleEvent event = inboundListener.sensedEvent;
        assertNotNull(event);
        assertEquals(sync, event.getExchangePattern().hasResponse());
        assertNotNull(event.getMessage());
        return event;
    }
View Full Code Here

    }

    protected MuleEvent assertMessageSentSame(boolean sync) throws MuleException
    {
        assertMessageSent(sync);
        MuleEvent event = inboundListener.sensedEvent;
        assertEquals(inMessage, event.getMessage());
        assertEquals(TEST_MESSAGE, event.getMessageAsString());
        assertEquals("value1", event.getMessage().getOutboundProperty("prop1"));
        return event;
    }
View Full Code Here

        return event;
    }

    protected void assertMessageNotSent() throws MuleException
    {
        MuleEvent event = inboundListener.sensedEvent;
        assertNull(event);
    }
View Full Code Here

        assertEquals(MessageExchangePattern.REQUEST_RESPONSE, ep.getExchangePattern());
        assertEquals(2002, ep.getResponseTimeout());
        assertTrue(ep instanceof InboundEndpoint);

        // Test MuleEvent timeout proporgation
        MuleEvent event = new DefaultMuleEvent(new DefaultMuleMessage("hello", muleContext),
            (InboundEndpoint) ep, MuleTestUtils.getTestSession(muleContext));
        assertEquals(2002, event.getTimeout());

        ImmutableEndpoint ep2 = muleContext.getEndpointFactory().getInboundEndpoint(
            "test://hello?connector=testConnector1");

        event = new DefaultMuleEvent(new DefaultMuleMessage("hello", muleContext), (InboundEndpoint) ep2,
            MuleTestUtils.getTestSession(muleContext));
        // default event timeout set in the test config file
        assertEquals(1001, event.getTimeout());
    }
View Full Code Here

            {
                StringBuffer buffer = new StringBuffer(128);

                for (Iterator<MuleEvent> iterator = events.iterator(); iterator.hasNext();)
                {
                    MuleEvent event = iterator.next();
                    try
                    {
                        buffer.append(event.transformMessageToString());
                    }
                    catch (TransformerException e)
                    {
                        throw new AggregationException(events, null, e);
                    }
View Full Code Here

   
    public static MuleEvent aggregateEvents(EventGroup events) throws Exception
    {
        LoanQuote lowestQuote = null;
        LoanQuote quote = null;
        MuleEvent event = null;

        for (Iterator iterator = events.iterator(); iterator.hasNext();)
        {
            event = (MuleEvent)iterator.next();
            Object o = event.getMessage().getPayload();
            if(o instanceof LoanQuote)
            {
                quote = (LoanQuote)o;
            }
            else
            {
                throw new IllegalArgumentException("Object received by Aggregator is not of expected type. Wanted: "
                        + LoanQuote.class.getName() + " Got: " + o);
            }
            logger.info(LocaleMessage.processingQuote(quote));

            if (lowestQuote == null)
            {
                lowestQuote = quote;
            }
            else
            {
                if (quote.getInterestRate() < lowestQuote.getInterestRate())
                {
                    lowestQuote = quote;
                }
            }
        }

        logger.info(LocaleMessage.lowestQuote(lowestQuote));
        return new DefaultMuleEvent(new DefaultMuleMessage(lowestQuote, event.getMessage(),
            event.getMuleContext()), event);
    }
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.