Пример #1
0
  public ServiceEndpointServer build() {

    final ServiceBundle serviceBundle;

    serviceBundle =
        getFactory()
            .createServiceBundle(
                uri,
                getRequestQueueBuilder(),
                getResponseQueueBuilder(),
                getWebResponseQueueBuilder(),
                getFactory(),
                eachServiceInItsOwnThread,
                this.getBeforeMethodCall(),
                this.getBeforeMethodCallAfterTransform(),
                this.getArgTransformer(),
                true,
                getSystemManager(),
                getHealthService(),
                getStatsCollector(),
                getTimer(),
                getStatsFlushRateSeconds(),
                getCheckTimingEveryXCalls(),
                getCallbackManager(),
                getEventManager(),
                getBeforeMethodSent(),
                getBeforeMethodCallOnServiceQueue(),
                getAfterMethodCallOnServiceQueue());

    final ServiceEndpointServer serviceEndpointServer =
        getFactory()
            .createServiceServer(
                getHttpServer(),
                getEncoder(),
                getParser(),
                serviceBundle,
                getJsonMapper(),
                this.getTimeoutSeconds(),
                this.getNumberOfOutstandingRequests(),
                this.getRequestQueueBuilder().getBatchSize(),
                this.getFlushInterval(),
                this.getSystemManager(),
                getEndpointName(),
                getServiceDiscovery(),
                getPort(),
                getTtlSeconds(),
                getHealthService());

    if (serviceEndpointServer != null && qBitSystemManager != null) {
      qBitSystemManager.registerServer(serviceEndpointServer);
    }

    if (services != null) {
      serviceEndpointServer.initServices(services);
    }
    return serviceEndpointServer;
  }
Пример #2
0
  /**
   * Builds a service.
   *
   * @return new service queue
   */
  public ServiceQueue build() {

    if (debug) logger.debug("Building a service");

    ServiceQueueSizer serviceQueueSizer = null;

    if (statsConfig != null) {

      serviceQueueSizer = new ServiceQueueSizer();
      this.addQueueCallbackHandler(
          new ServiceStatsListener(
              statsConfig.serviceName,
              statsConfig.statsCollector,
              getTimer(),
              statsConfig.flushTimeSeconds,
              TimeUnit.SECONDS,
              statsConfig.sampleEvery,
              serviceQueueSizer));
    }

    ServiceQueue serviceQueue =
        new ServiceQueueImpl(
            this.getRootAddress(),
            this.getServiceAddress(),
            this.getServiceObject(),
            this.getRequestQueueBuilder(),
            this.getResponseQueueBuilder(),
            QBit.factory().createServiceMethodHandler(this.isInvokeDynamic()),
            this.getResponseQueue(),
            this.isAsyncResponse(),
            this.isHandleCallbacks(),
            this.getSystemManager(),
            buildQueueCallBackHandler(),
            getCallbackManager());

    if (serviceQueueSizer != null) {
      serviceQueueSizer.setServiceQueue(serviceQueue);
    }

    if (qBitSystemManager != null) {
      qBitSystemManager.registerService(serviceQueue);
    }

    return serviceQueue;
  }