Uploaded image for project: 'ServiceMix Components'
  1. ServiceMix Components
  2. SMXCOMP-182

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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • None
    • 2013.02
    • servicemix-common
    • None

    Description

      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); }

      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            bpachol Ben Pachol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: