Package org.mule.api.routing

Examples of org.mule.api.routing.CouldNotRouteOutboundMessageException


        String endpointName;

        String prop = expressionConfig.getFullExpression(expressionManager);
        if (!expressionManager.isValidExpression(prop))
        {
            throw new CouldNotRouteOutboundMessageException(
                    CoreMessages.expressionInvalidForProperty("expression", prop), event, null);
        }

        Object property = null;
        try
        {
            property = expressionManager.evaluate(prop, message);
        }
        catch (ExpressionRuntimeException e)
        {
            logger.error(e.getMessage());
        }

        if (property == null && getDefaultEndpointName() == null)
        {
            throw new CouldNotRouteOutboundMessageException(
                    CoreMessages.expressionResultWasNull(
                        expressionConfig.getFullExpression(expressionManager)), event, null);
        }
        else if (property == null)
        {
            logger.info("Expression: " + prop + " returned null, using default endpoint: " + getDefaultEndpointName());
            property = getDefaultEndpointName();
        }

        if (property instanceof String)
        {
            endpoints = new ArrayList<Object>(1);
            endpoints.add(property);
        }
        else if (property instanceof List)
        {
            endpoints = (List<Object>) property;
        }
        else
        {
            throw new CouldNotRouteOutboundMessageException(CoreMessages.propertyIsNotSupportedType(
                    expressionConfig.getFullExpression(expressionManager),
                    new Class[]{String.class, List.class}, property.getClass()), event, null);
        }

        List<MuleEvent> results = new ArrayList<MuleEvent>(endpoints.size());

        for (Iterator<Object> iterator = endpoints.iterator(); iterator.hasNext();)
        {
            endpointName = iterator.next().toString();

            if (StringUtils.isEmpty(endpointName))
            {
                throw new CouldNotRouteOutboundMessageException(
                        CoreMessages.objectIsNull("Endpoint Name: " + expressionConfig.getFullExpression(expressionManager)), event, null);
            }
            MessageProcessor ep = null;
            try
            {
                ep = lookupEndpoint(endpointName);
                if (ep == null)
                {
                    throw new CouldNotRouteOutboundMessageException(CoreMessages.objectNotFound("Endpoint",
                            endpointName), event, null);
                }
                MuleEvent result = sendRequest(event, message, ep, true);
                if (result != null)
                {
                    results.add(result);
                }
            }
            catch (MuleException e)
            {
                throw new CouldNotRouteOutboundMessageException(event, ep, e);
            }
        }
        return resultsHandler.aggregateResults(results, event, muleContext);
    }
View Full Code Here


            }

        }
        catch (MuleException e)
        {
            throw new CouldNotRouteOutboundMessageException(message, endpoint, e);
        }
        return resultToReturn;
    }
View Full Code Here

            }

        }
        catch (MuleException e)
        {
            throw new CouldNotRouteOutboundMessageException(message, endpoint, e);
        }
        return resultToReturn;
    }
View Full Code Here

    protected List<Object> getRecipients(MuleEvent event) throws CouldNotRouteOutboundMessageException
    {
        String expr = getFullExpression();
        if (!muleContext.getExpressionManager().isValidExpression(expr))
        {
            throw new CouldNotRouteOutboundMessageException(
                    CoreMessages.expressionInvalidForProperty("expression", expr), event, null);
        }

        Object msgRecipients = muleContext.getExpressionManager().evaluate(expr, event);
        if (msgRecipients == null)
        {
            throw new CouldNotRouteOutboundMessageException(
                    CoreMessages.propertyIsNotSetOnEvent(getFullExpression()), event, null);
        }
        else if (msgRecipients instanceof String)
        {
            Object[] recipients = StringUtils.splitAndTrim(msgRecipients.toString(), " ,;:");
            return Arrays.asList(recipients);
        }
        else if (msgRecipients instanceof List)
        {
            return new ArrayList<Object>((List<?>) msgRecipients);
        }
        else
        {
            logger.error("Recipients on message are neither String nor List but: " + msgRecipients.getClass());
            throw new CouldNotRouteOutboundMessageException(
                    CoreMessages.propertyIsNotSupportedType(getFullExpression(), new Class[]{String.class, List.class}, msgRecipients.getClass()), event, null);
        }
    }
View Full Code Here

            }

        }
        catch (MuleException e)
        {
            throw new CouldNotRouteOutboundMessageException(resultToReturn, endpoint, e);
        }
        return resultToReturn;
    }
View Full Code Here

                boolean lastEndpoint = !iterator.hasNext();

                // TODO MULE-4476
                if (!lastEndpoint && !endpoint.getExchangePattern().hasResponse())
                {
                    throw new CouldNotRouteOutboundMessageException(
                        MessageFactory.createStaticMessage("The ExceptionBasedRouter does not support asynchronous endpoints, make sure all endpoints on the router are configured as synchronous"), event, endpoint);
                }

                if (endpoint.getExchangePattern().hasResponse())
                {
                    MuleMessage resultMessage = null;
                    result = sendRequest(event, request, endpoint, true);
                    if (result != null && !VoidMuleEvent.getInstance().equals(result))
                    {
                        resultMessage = result.getMessage();
                    }
                    if (resultMessage != null)
                    {
                        resultMessage.applyTransformers(result, endpoint.getResponseTransformers());
                    }
                    if (!exceptionPayloadAvailable(resultMessage))
                    {
                        if (logger.isDebugEnabled())
                        {
                            logger.debug("Successful invocation detected, stopping further processing.");
                        }
                        success = true;
                        break;
                    }
                }
                else
                {
                    sendRequest(event, request, endpoint, false);
                    success = true;
                    break;
                }
            }
            catch (MuleException e)
            {
                logger.info("Failed to send/dispatch to endpoint: " + endpoint.getEndpointURI().toString()
                            + ". Error was: " + e.getMessage() + ". Trying next endpoint");
            }
        }

        if (!success)
        {
            throw new CouldNotRouteOutboundMessageException(event, endpoint);
        }

        return result;
    }
View Full Code Here

                    sendRequest(event, sendMessage, part.getEndpoint(), false);
                }
            }
            catch (MuleException e)
            {
                throw new CouldNotRouteOutboundMessageException(event, part.getEndpoint(), e);
            }
        }

        return resultsHandler.aggregateResults(results, event, muleContext);
    }
View Full Code Here

            }
            result = sendRequest(event, message, ep, true);
        }
        catch (MuleException e)
        {
            throw new CouldNotRouteOutboundMessageException(event, routes.get(0), e);
        }

        return result;
    }
View Full Code Here

        String endpointName;

        String prop = expressionConfig.getFullExpression(expressionManager);
        if (!expressionManager.isValidExpression(prop))
        {
            throw new CouldNotRouteOutboundMessageException(
                    CoreMessages.expressionInvalidForProperty("expression", prop), event, null);
        }

        Object property = null;
        try
        {
            property = expressionManager.evaluate(prop, event);
        }
        catch (ExpressionRuntimeException e)
        {
            logger.error(e.getMessage());
        }

        if (property == null && getDefaultEndpointName() == null)
        {
            throw new CouldNotRouteOutboundMessageException(
                    CoreMessages.expressionResultWasNull(
                        expressionConfig.getFullExpression(expressionManager)), event, null);
        }
        else if (property == null)
        {
            logger.info("Expression: " + prop + " returned null, using default endpoint: " + getDefaultEndpointName());
            property = getDefaultEndpointName();
        }

        if (property instanceof String)
        {
            endpoints = new ArrayList<Object>(1);
            endpoints.add(property);
        }
        else if (property instanceof List)
        {
            endpoints = (List<Object>) property;
        }
        else
        {
            throw new CouldNotRouteOutboundMessageException(CoreMessages.propertyIsNotSupportedType(
                    expressionConfig.getFullExpression(expressionManager),
                    new Class[]{String.class, List.class}, property.getClass()), event, null);
        }

        List<MuleEvent> results = new ArrayList<MuleEvent>(endpoints.size());

        for (Iterator<Object> iterator = endpoints.iterator(); iterator.hasNext();)
        {
            endpointName = iterator.next().toString();

            if (StringUtils.isEmpty(endpointName))
            {
                throw new CouldNotRouteOutboundMessageException(
                        CoreMessages.objectIsNull("Endpoint Name: " + expressionConfig.getFullExpression(expressionManager)), event, null);
            }
            MessageProcessor ep = null;
            try
            {
                ep = lookupEndpoint(endpointName);
                if (ep == null)
                {
                    throw new CouldNotRouteOutboundMessageException(CoreMessages.objectNotFound("Endpoint",
                            endpointName), event, null);
                }
                MuleEvent result = sendRequest(event, message, ep, true);
                if (result != null && !VoidMuleEvent.getInstance().equals(result))
                {
                    results.add(result);
                }
            }
            catch (MuleException e)
            {
                throw new CouldNotRouteOutboundMessageException(event, ep, e);
            }
        }
        return resultsHandler.aggregateResults(results, event, muleContext);
    }
View Full Code Here

                }
            }
        }
        catch (MuleException e)
        {
            throw new CouldNotRouteOutboundMessageException(event, routes.get(0), e);
        }
        return resultsHandler.aggregateResults(results, event, muleContext);
    }
View Full Code Here

TOP

Related Classes of org.mule.api.routing.CouldNotRouteOutboundMessageException

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.