You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by "Ben Pachol (JIRA)" <ji...@apache.org> on 2007/05/18 16:40:34 UTC

[jira] Created: (SM-953) Add meaningful exception when trying to send message exchange before endpoint activation

Add meaningful exception when trying to send message exchange before endpoint activation
----------------------------------------------------------------------------------------

                 Key: SM-953
                 URL: https://issues.apache.org/activemq/browse/SM-953
             Project: ServiceMix
          Issue Type: Improvement
          Components: servicemix-common
            Reporter: Ben Pachol
            Priority: Trivial


A message exchange in PollingEndpoint.java's Poll method cannot be sent because the endpoint has yet to have been activated at that point.  A meaningful exception would help.

This example code is an endpoint class derived from PollingEndpoint that gives a null pointer exception which isn't very meaningful.

public void poll() throws Exception
    {
        invokeIdentityService();
    }
   
    private boolean invokeIdentityService() throws MessagingException {
   
        ComponentContext ctx = getServiceUnit().getComponent().getComponentContext();
       
        QName identityService = new QName("http://servicemix.apache.org/servicemanagerassembly",
         "httpService");
         
        InOut identityExchange = exchangeFactory.createInOutExchange();

        configureTarget("Identity Service", identityExchange, ctx,
        null, identityService, "soap", "");

        NormalizedMessage in = identityExchange.createMessage();
        in.setContent(new StringSource("Testing"));
        identityExchange.setInMessage(in);
       
        sendSync(identityExchange);

        NormalizedMessage out = identityExchange.getOutMessage();
        boolean login = false;
        if (out != null) {
            //login = support.parseIdentityOutMessage(out.getContent());
        } else {
            // TODO: how should we handle faults
        }
        done(identityExchange);

        return login;
    }

    public void configureTarget(String serviceDesc, MessageExchange
    exchange, ComponentContext context, QName _interface, QName service,
    String endpoint, String uri) throws MessagingException {

            if (_interface == null && service == null && uri == null) {
                throw new MessagingException(serviceDesc + ": interface, service or uri should be specified");
            }
            /*if (uri != null) {
                URIResolver.configureExchange(exchange, context, uri);
            }*/
            if (_interface != null) {
                exchange.setInterfaceName(_interface);
            }

            if (service != null) {
                exchange.setService(service);
                if (endpoint != null) {
                    ServiceEndpoint se = context.getEndpoint(service, endpoint);
                    exchange.setEndpoint(se);
                }
            }
        } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.