예제 #1
0
  @Override
  public void subscribeToTransportAdaptor() {
    if (this.subscriptionId == null) {
      int tenantId =
          PrivilegedCarbonContext.getCurrentContext(this.axisConfiguration).getTenantId();
      String inputTransportAdaptorName =
          eventBuilderConfiguration.getInputStreamConfiguration().getTransportAdaptorName();

      try {
        InputTransportAdaptorConfiguration inputTransportAdaptorConfiguration =
            EventBuilderServiceValueHolder.getInputTransportAdaptorManagerService()
                .getInputTransportAdaptorConfiguration(inputTransportAdaptorName, tenantId);
        this.subscriptionId =
            EventBuilderServiceValueHolder.getInputTransportAdaptorService()
                .subscribe(
                    inputTransportAdaptorConfiguration,
                    eventBuilderConfiguration
                        .getInputStreamConfiguration()
                        .getInputTransportAdaptorMessageConfiguration(),
                    new XmlInputTransportListener(),
                    axisConfiguration);
      } catch (InputTransportAdaptorManagerConfigurationException e) {
        log.error(
            "Cannot subscribe to input transport adaptor "
                + inputTransportAdaptorName
                + ":\n"
                + e.getMessage());
        throw new EventBuilderConfigurationException(e);
      }
    }
  }
예제 #2
0
 @Override
 public void unsubscribeFromTransportAdaptor(
     InputTransportAdaptorConfiguration inputTransportAdaptorConfiguration) {
   if (this.subscriptionId != null) {
     EventBuilderServiceValueHolder.getInputTransportAdaptorService()
         .unsubscribe(
             eventBuilderConfiguration
                 .getInputStreamConfiguration()
                 .getInputTransportAdaptorMessageConfiguration(),
             inputTransportAdaptorConfiguration,
             axisConfiguration,
             this.subscriptionId);
     this.subscriptionId = null;
   }
 }