@Inject
  public AsyncEventServiceImpl(
      final QueueManagerFactory queueManagerFactory,
      final IndexProcessorFig indexProcessorFig,
      final IndexProducer indexProducer,
      final MetricsFactory metricsFactory,
      final EntityCollectionManagerFactory entityCollectionManagerFactory,
      final IndexLocationStrategyFactory indexLocationStrategyFactory,
      final EntityIndexFactory entityIndexFactory,
      final EventBuilder eventBuilder,
      final MapManagerFactory mapManagerFactory,
      final QueueFig queueFig,
      @EventExecutionScheduler final RxTaskScheduler rxTaskScheduler) {
    this.indexProducer = indexProducer;

    this.entityCollectionManagerFactory = entityCollectionManagerFactory;
    this.indexLocationStrategyFactory = indexLocationStrategyFactory;
    this.entityIndexFactory = entityIndexFactory;
    this.eventBuilder = eventBuilder;

    final MapScope mapScope =
        new MapScopeImpl(CpNamingUtils.getManagementApplicationId(), "indexEvents");

    this.esMapPersistence = mapManagerFactory.createMapManager(mapScope);

    this.rxTaskScheduler = rxTaskScheduler;

    QueueScope queueScope = new QueueScopeImpl(QUEUE_NAME, QueueScope.RegionImplementation.ALL);
    this.queue = queueManagerFactory.getQueueManager(queueScope);

    this.indexProcessorFig = indexProcessorFig;
    this.queueFig = queueFig;

    this.writeTimer = metricsFactory.getTimer(AsyncEventServiceImpl.class, "async_event.write");
    this.readTimer = metricsFactory.getTimer(AsyncEventServiceImpl.class, "async_event.read");
    this.ackTimer = metricsFactory.getTimer(AsyncEventServiceImpl.class, "async_event.ack");
    this.indexErrorCounter =
        metricsFactory.getCounter(AsyncEventServiceImpl.class, "async_event.error");
    this.messageCycle =
        metricsFactory.getHistogram(AsyncEventServiceImpl.class, "async_event.message_cycle");

    // wire up the gauge of inflight message
    metricsFactory.addGauge(
        AsyncEventServiceImpl.class,
        "async-event.inflight",
        new Gauge<Long>() {
          @Override
          public Long getValue() {
            return inFlight.longValue();
          }
        });

    start();
  }
  @Override
  public void init(ServiceInfo info) {
    super.init(info);
    smf = getApplicationContext().getBean(ServiceManagerFactory.class);
    emf = getApplicationContext().getBean(EntityManagerFactory.class);

    Properties props = (Properties) getApplicationContext().getBean("properties");
    metricsService =
        getApplicationContext().getBean(Injector.class).getInstance(MetricsFactory.class);
    postMeter = metricsService.getMeter(NotificationsService.class, "collection.post_requests");
    postTimer = metricsService.getTimer(this.getClass(), "collection.post_requests");
    JobScheduler jobScheduler = new JobScheduler(sm, em);
    String name = ApplicationQueueManagerImpl.getQueueNames(props);
    QueueScope queueScope = new QueueScopeImpl(name, QueueScope.RegionImplementation.LOCAL);
    queueManagerFactory =
        getApplicationContext().getBean(Injector.class).getInstance(QueueManagerFactory.class);
    QueueManager queueManager = queueManagerFactory.getQueueManager(queueScope);
    notificationQueueManager =
        new ApplicationQueueManagerImpl(jobScheduler, em, queueManager, metricsService, props);
    gracePeriod = JobScheduler.SCHEDULER_GRACE_PERIOD;
  }