public void restorePreviousSync() {
      if (_sync == null) {
        return;
      }

      ProxyModeThreadLocal.setForceSync(_forceSync);

      MessageBus messageBus = MessageBusUtil.getMessageBus();

      for (Destination destination : _asyncServiceDestinations) {
        messageBus.replace(destination);
      }

      _asyncServiceDestinations.clear();

      for (String absentDestinationName : _absentDestinationNames) {
        messageBus.removeDestination(absentDestinationName);
      }
    }
  public void destroy() {
    MessageBus messageBus = getMessageBus();

    for (Map.Entry<String, List<MessageListener>> messageListeners : _messageListeners.entrySet()) {

      String destinationName = messageListeners.getKey();

      for (MessageListener messageListener : messageListeners.getValue()) {

        messageBus.unregisterMessageListener(destinationName, messageListener);
      }
    }

    for (Destination destination : _destinations) {
      messageBus.removeDestination(destination.getName());

      destination.close();
    }

    for (Map.Entry<String, List<DestinationEventListener>> destinationEventListeners :
        _specificDestinationEventListeners.entrySet()) {

      String destinationName = destinationEventListeners.getKey();

      for (DestinationEventListener destinationEventListener :
          destinationEventListeners.getValue()) {

        messageBus.removeDestinationEventListener(destinationName, destinationEventListener);
      }
    }

    for (DestinationEventListener destinationEventListener : _globalDestinationEventListeners) {

      messageBus.removeDestinationEventListener(destinationEventListener);
    }
  }