Package org.mule.api.endpoint

Examples of org.mule.api.endpoint.OutboundEndpoint


        assertEquals(TEST_MEP, endpoint.getExchangePattern());
    }

    public void testOutboundEndpointCreation() throws MuleException
    {
        OutboundEndpoint endpoint = client.createOutboundEndpoint(TEST_URI, TEST_MEP, new Long(
            TEST_RESPONSE_TIMEOUT));
        assertEquals(TEST_URI, endpoint.getEndpointURI().getUri().toString());
        assertEquals(TEST_MEP, endpoint.getExchangePattern());
        assertEquals(TEST_RESPONSE_TIMEOUT, endpoint.getResponseTimeout());
    }
View Full Code Here


     * @param message the message to send
     * @throws org.mule.api.MuleException
     */
    public void dispatch(String url, MuleMessage message) throws MuleException
    {
        OutboundEndpoint endpoint = getOutboundEndpoint(url, MessageExchangePattern.ONE_WAY, null);
        MuleEvent event = getEvent(message, MessageExchangePattern.ONE_WAY);
        endpoint.process(event);
    }
View Full Code Here

     *         explicitly sets a return as <code>null</code>.
     * @throws org.mule.api.MuleException
     */
    public MuleMessage send(String url, MuleMessage message, int timeout) throws MuleException
    {
        OutboundEndpoint endpoint =
            getOutboundEndpoint(url, MessageExchangePattern.REQUEST_RESPONSE, timeout);
       
        MuleEvent event = getEvent(message, MessageExchangePattern.REQUEST_RESPONSE);
        event.setTimeout(timeout);

        MuleEvent response = endpoint.process(event);
        if (response != null)
        {
            return response.getMessage();
        }
        else
View Full Code Here

        // with the same key that has been created and put in the cache by another
        // thread. To avoid this we test for the result of putIfAbsent result and if
        // it is non-null then an endpoint was created and added concurrently and we
        // return this instance instead.
        String key = String.format("%1s:%2s:%3s", uri, exchangePattern, responseTimeout);
        OutboundEndpoint endpoint = (OutboundEndpoint) outboundEndpointCache.get(key);
        if (endpoint == null)
        {
            EndpointBuilder endpointBuilder =
                muleContext.getEndpointFactory().getEndpointBuilder(uri);
            endpointBuilder.setExchangePattern(exchangePattern);
            if (responseTimeout != null && responseTimeout > 0)
            {
                endpointBuilder.setResponseTimeout(responseTimeout.intValue());
            }
            endpoint = muleContext.getEndpointFactory().getOutboundEndpoint(endpointBuilder);
            OutboundEndpoint concurrentlyAddedEndpoint =
                (OutboundEndpoint) outboundEndpointCache.putIfAbsent(key, endpoint);
            if (concurrentlyAddedEndpoint != null)
            {
                return concurrentlyAddedEndpoint;
            }
View Full Code Here

            messageProperties = new HashMap<String, Object>();
        }
        messageProperties.put(MuleProperties.MULE_REMOTE_SYNC_PROPERTY, "false");
        MuleMessage message = new DefaultMuleMessage(payload, messageProperties, muleContext);
       
        OutboundEndpoint endpoint =
            getOutboundEndpoint(url, MessageExchangePattern.REQUEST_RESPONSE, null);
        MuleEvent event = getEvent(message, MessageExchangePattern.REQUEST_RESPONSE);
        endpoint.process(event);
    }
View Full Code Here

        return send(url, new DefaultMuleMessage(payload, messageProperties, muleContext));
    }

    public MuleMessage send(String url, MuleMessage message) throws MuleException
    {
        OutboundEndpoint endpoint = endpointCache.getOutboundEndpoint(url, MessageExchangePattern.REQUEST_RESPONSE, null);
        return returnMessage(endpoint.process(createMuleEvent(message, endpoint)));
    }
View Full Code Here

    }

    public MuleMessage send(String url, MuleMessage message, long timeout) throws MuleException
    {
        OutboundEndpoint endpoint = endpointCache.getOutboundEndpoint(url, MessageExchangePattern.REQUEST_RESPONSE, timeout);
        return returnMessage(endpoint.process(createMuleEvent(message, endpoint)));
    }
View Full Code Here

        return returnMessage(endpoint.process(createMuleEvent(message, endpoint)));
    }

    public void dispatch(String url, MuleMessage message) throws MuleException
    {
        OutboundEndpoint endpoint = endpointCache.getOutboundEndpoint(url, MessageExchangePattern.ONE_WAY, null);
        endpoint.process(createMuleEvent(message, endpoint));
    }
View Full Code Here

    }

    public MuleMessage process(String uri, MessageExchangePattern mep, MuleMessage message)
        throws MuleException
    {
        OutboundEndpoint endpoint = endpointCache.getOutboundEndpoint(uri, mep, null);
        return returnMessage(endpoint.process(createMuleEvent(message, endpoint)));
    }
View Full Code Here

                message.setCorrelationGroupSize(recipients.size());
            }
        }

        MuleEvent result = null;
        OutboundEndpoint endpoint = null;
        MuleMessage request = null;
        boolean success = false;

        for (Iterator iterator = recipients.iterator(); iterator.hasNext();)
        {
            request = new DefaultMuleMessage(message.getPayload(), message, muleContext);
            try
            {
                endpoint = getRecipientEndpoint(request, iterator.next());
                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)
                    {
                        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)
View Full Code Here

TOP

Related Classes of org.mule.api.endpoint.OutboundEndpoint

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.