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

Registration/deregistration problem for consumer endpoint

    XMLWordPrintableJSON

    Details

      Description

      I think there is registration/deregistration problem for consumer endpoint in servicemix-cxf-bc 2009.01 and 2009.02-SNAPSHOT component.

      I have SA with SU installed on servicemix-cxf-bc component. SU has only one endpoint. Problem with registration/deregistation consumer endpoint happens in case of problem with connection initilization to JMS message broker.

      There is no possiblity to deregister endpoint correctly in case of no possibility to start SU, for example because of wrong connectivy parameters in endpoint consumer configuration files: xbean.xml, config file for cxf bus, wsdl file or JMS message broker wrong configuration. There is no possibity to deregister endpoint even with SA undeploy process, bacause of SU remains in "shutdown" state if there was problem at SU startup. If SU in shutdown state then SMX does not deregister endpoints for this SU. (please see code listing). Such behavior leads to error message: "An endpoint is already registered for key: FOO BAR" if user tries to redeploy SA with changed endpoint configuration, but with the same endpoint name. There is only one way to deregister endpoint - restart SMX, but it is not very good way if user needs use SMX in non-stop mode.

      Please find below related source code parts with small comments.

      org.apache.servicemix.jbi.framework.ServiceAssemblyLifeCycle.java

         public synchronized String shutDown(boolean writeState) throws Exception {
              LOG.info("Shutting down service assembly: " + getName());
              List<Element> componentFailures = new ArrayList<Element>();
              for (int i = 0; i < sus.length; i++) {
                  if (sus[i].isStarted()) {
                      try {
                          sus[i].stop();
                      } catch (DeploymentException e) {
                          componentFailures.add(getComponentFailure(e, "shutDown", sus[i].getComponentName()));
                      }
                  }
              }
              for (int i = 0; i < sus.length; i++) {
                  if (sus[i].isStopped()) {  //<-  false for SU in shutdown state.
                      try {
                          sus[i].shutDown();
                      } catch (DeploymentException e) {
                          componentFailures.add(getComponentFailure(e, "shutDown", sus[i].getComponentName()));
                      }
                  }
              }
              if (componentFailures.size() == 0) {
                  currentState = SHUTDOWN;
                  if (writeState) {
                      writeRunningState();
                  }
                  fireEvent(ServiceAssemblyEvent.ASSEMBLY_SHUTDOWN);
                  return ManagementSupport.createSuccessMessage("shutDown");
              } else {
                  throw ManagementSupport.failure("shutDown", componentFailures);
              }
          }
      

      org.apache.servicemix.common.DefaultServiceUnit.java

          public synchronized void init() throws Exception {
              if (this.status == LifeCycleMBean.SHUTDOWN) {
                  // Activate endpoints
                  List<Endpoint> activated = new ArrayList<Endpoint>();
                  try {
                      for (Endpoint endpoint : getEndpoints()) {
                          endpoint.activate();  // <-  registration inside activate method of cxf-bc consumer endpoint
                          activated.add(endpoint);
                      }
                      this.status = LifeCycleMBean.STOPPED;
                  } catch (Exception e) {
                      // Deactivate activated endpoints
                      for (Endpoint endpoint : activated) {
                          try {
                              endpoint.deactivate();  // <- deregistration does not work, if (1) thown exception, because of there is no broken endpoint in list "activated"
                          } catch (Exception e2) {
                              // do nothing
                          }
                      }
                      throw e;
                  }
              }
          }
      

      org.apache.servicemix.cxfbc.CxfBcConsumer.java

          @Override
          public void activate() throws Exception {
              super.activate(); //<-  registration inside activate method. There is no recovery process for registration, in case of any problems after super.activate() call.
              registerListServiceHandler();                                        
              applyFeatures();
              checkJmsTransportTransaction();
              server.start(); 
          }
      

      I propose the following fix on BC level:

          @Override
          public void activate() throws Exception {
              super.activate();
              try {
              	registerListServiceHandler();
              	applyFeatures();
              	checkJmsTransportTransaction();
              	server.start();
              } catch (Exception ex){
              	super.deactivate();   //<- recovery process for registration in case of any problems with connection.
              	throw ex;
              }
          }
      

        Attachments

          Activity

            People

            • Assignee:
              ffang Freeman Yue Fang
              Reporter:
              alexanderz Alexander Zobkov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: