Package org.mule.api

Examples of org.mule.api.MuleSession


//        }
      

        MuleEvent replyEvent = null;
        MuleMessage reply;
        MuleSession session = new DefaultMuleSession(flow, muleContext);

        try
        {
            replyEvent = router.process(new DefaultMuleEvent(message, router.getEndpoint()
                .getExchangePattern(), session));
View Full Code Here


    @Override
    public MuleEvent route(MuleEvent event) throws RoutingException
    {
        MuleMessage message = event.getMessage();
        MuleSession session = event.getSession();
        if (messageSize == 0 && numberOfMessages < 2)
        {
            return super.route(event);
        }
        else if (messageSize > 0)
View Full Code Here

    protected MuleContext muleContext;

    public MuleEvent process(final MuleEvent event) throws MessagingException
    {
        MuleMessage message = event.getMessage();
        MuleSession session = event.getSession();
        MuleEvent result;
        boolean matchfound = false;

        for (Iterator<MatchableMessageProcessor> iterator = getRoutes().iterator(); iterator.hasNext();)
        {
            OutboundRouter outboundRouter = (OutboundRouter) iterator.next();

            final MuleMessage outboundRouterMessage;
            // Create copy of message for router 1..n-1 if matchAll="true" or if
            // routers require copy because it may mutate payload before match is
            // chosen
            if (iterator.hasNext()
                && (isMatchAll() || ((outboundRouter instanceof TransformingMatchable) && ((TransformingMatchable) outboundRouter).isTransformBeforeMatch())))
            {
                if (((DefaultMuleMessage) message).isConsumable())
                {
                    throw new MessagingException(CoreMessages.cannotCopyStreamPayload(message.getPayload()
                        .getClass()
                        .getName()), event);
                }
                outboundRouterMessage = new DefaultMuleMessage(message.getPayload(), message, muleContext);
            }
            else
            {
                outboundRouterMessage = message;
            }

            try
            {
                if (outboundRouter.isMatch(outboundRouterMessage))
                {
                    matchfound = true;
                    // Manage outbound only transactions here
                    final OutboundRouter router = outboundRouter;
   
                    result = router.process(event);
   
                    if (!isMatchAll())
                    {
                        return result;
                    }
                }
            }
            catch (MessagingException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new RoutingException(event, outboundRouter, e);
            }
        }

        if (!matchfound && getCatchAllStrategy() != null)
        {
            if (logger.isDebugEnabled())
            {
                logger.debug("Message did not match any routers on: " + session.getFlowConstruct().getName()
                             + " invoking catch all strategy");
            }
            return catchAll(event);
        }
        else if (!matchfound)
        {
            logger.warn("Message did not match any routers on: "
                        + session.getFlowConstruct().getName()
                        + " and there is no catch all strategy configured on this router.  Disposing message "
                        + message);
        }
        return event;
    }
View Full Code Here

        {
            message = new DefaultMuleMessage(payload, message, muleContext);
        }

        message.addProperties(action.getProperties());
        MuleSession session = new DefaultMuleSession(muleContext);

        MuleEvent event = new DefaultMuleEvent(message, serverEndpoint.getExchangePattern(), session);
        event.setTimeout(timeout);
        if (logger.isDebugEnabled())
        {
View Full Code Here

    }

    @Override
    public MuleEvent process(MuleEvent event) throws MuleException
    {
        MuleSession calledSession = new DefaultMuleSession(event.getSession(), this);
        MuleEvent newEvent = new DefaultMuleEvent(event.getMessage(), event.getEndpoint(), event,
            calledSession);
        RequestContext.setEvent(newEvent);
        try
        {
View Full Code Here

    }

    public void testCorrelationGroupSizePropertySet() throws Exception
    {
        Service testService = getTestService("test", Apple.class);
        MuleSession session = getTestSession(testService, muleContext);

        OutboundEndpoint endpoint = getTestOutboundEndpoint("Test1Endpoint",
            "test://endpoint?exchangePattern=request-response");
        ListMessageSplitter router = new ListMessageSplitter();
        router.setFilter(null);
View Full Code Here

        MuleMessage message = new DefaultMuleMessage("test event", muleContext);

        assertTrue(router.isMatch(message));

        // exception to throw
        MuleSession session = (MuleSession)mockSession.proxy();
        MuleEvent eventToThrow = new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, session);
        MuleException rex = new RoutingException(eventToThrow, endpoint1);
        mockendpoint1.expectAndThrow("process", RouterTestUtils.getArgListCheckerMuleEvent(), rex);
        mockendpoint2.expectAndThrow("process", RouterTestUtils.getArgListCheckerMuleEvent(), rex);
        MuleEvent result = null;
View Full Code Here

        MuleMessage expectedResultMessage = new DefaultMuleMessage("Return event", muleContext);
        MuleEvent event = new OutboundRoutingTestEvent(expectedResultMessage, null, muleContext);

        assertTrue(router.isMatch(message));

        final MuleSession session = (MuleSession)mockSession.proxy();
        // exception to throw
        MuleEvent eventToThrow = new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, session);
        MuleException rex = new RoutingException(eventToThrow, endpoint1);
        // 1st failure
        mockendpoint1.expectAndThrow("process", RouterTestUtils.getArgListCheckerMuleEvent(), rex);
View Full Code Here

        MuleMessage expectedResultMessage = new DefaultMuleMessage("Return event", muleContext);
        MuleEvent event = new OutboundRoutingTestEvent(expectedResultMessage, null, muleContext);

        assertTrue(router.isMatch(message));

        final MuleSession session = (MuleSession)mockSession.proxy();
        // exception to throw
        MuleEvent eventToThrow = new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, session);
        MuleException rex = new RoutingException(eventToThrow, endpoint1);

        mockendpoint1.expectAndThrow("process", RouterTestUtils.getArgListCheckerMuleEvent(), rex);
View Full Code Here

        MuleMessage exPayloadMessage = new DefaultMuleMessage("there was a failure", muleContext);
        exPayloadMessage.setExceptionPayload(new DefaultExceptionPayload(new RuntimeException()));
        MuleEvent exPayloadMessageEvent = new OutboundRoutingTestEvent(exPayloadMessage, null, muleContext);


        final MuleSession session = (MuleSession)mockSession.proxy();
        // 1st failure
        mockendpoint1.expectAndReturn("process", RouterTestUtils.getArgListCheckerMuleEvent(),
            exPayloadMessageEvent);
        // next endpoint
        mockendpoint2.expectAndReturn("process", RouterTestUtils.getArgListCheckerMuleEvent(),
View Full Code Here

TOP

Related Classes of org.mule.api.MuleSession

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.