public IdentifierConsumerDocumentProducer(
      ProducerConsumerQueue<List<Serializable>> fromIdentifierListToEntities,
      MassIndexerProgressMonitor monitor,
      SessionFactory sessionFactory,
      CountDownLatch producerEndSignal,
      CacheMode cacheMode,
      Class<?> type,
      ExtendedSearchIntegrator searchFactory,
      String idName,
      BatchBackend backend,
      ErrorHandler errorHandler,
      Integer transactionTimeout,
      String tenantId) {
    this.source = fromIdentifierListToEntities;
    this.monitor = monitor;
    this.sessionFactory = sessionFactory;
    this.cacheMode = cacheMode;
    this.type = type;
    this.idName = idName;
    this.backend = backend;
    this.errorHandler = errorHandler;
    this.producerEndSignal = producerEndSignal;
    this.entityIndexBindings = searchFactory.getIndexBindings();
    this.transactionTimeout = transactionTimeout;
    this.tenantId = tenantId;
    this.transactionManager =
        ((SessionFactoryImplementor) sessionFactory)
            .getServiceRegistry()
            .getService(JtaPlatform.class)
            .retrieveTransactionManager();

    log.trace("created");
  }
 @Override
 public void run() {
   log.trace("started");
   Session session = sessionFactory.withOptions().tenantIdentifier(tenantId).openSession();
   session.setFlushMode(FlushMode.MANUAL);
   session.setCacheMode(cacheMode);
   session.setDefaultReadOnly(true);
   try {
     loadAllFromQueue(session);
   } catch (Exception exception) {
     errorHandler.handleException(log.massIndexerExceptionWhileTransformingIds(), exception);
   } finally {
     producerEndSignal.countDown();
     session.close();
   }
   log.trace("finished");
 }