private static Executor executorService(final String executorName, final String threadNameFormat, final MetricRegistry metricRegistry) { final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(threadNameFormat).build(); return new InstrumentedExecutorService( Executors.newCachedThreadPool(threadFactory), metricRegistry, name(BeatsTransport.class, executorName, "executor-service")); }
@Inject public MessageManagerService(MessageDao messageDao, @Named("redriver.noOfPersistenceWorkers") int noOfPersistenceWorkers, @Named("redriver.batchDelete.intervalms") Integer batchDeleteInterval, @Named("redriver.batchDelete.batchSize") Integer batchSize) { this.messageDao = messageDao; this.batchDeleteInterval = batchDeleteInterval; this.batchSize = batchSize; this.messagesToDelete = new ConcurrentLinkedQueue<>(); scheduledDeletionService = new InstrumentedScheduledExecutorService(Executors.newScheduledThreadPool(2), SharedMetricRegistries.getOrCreate(METRIC_REGISTRY_NAME), scheduledDeletionSvcName); persistenceExecutorService = new InstrumentedExecutorService(Executors.newFixedThreadPool(noOfPersistenceWorkers), SharedMetricRegistries.getOrCreate(METRIC_REGISTRY_NAME), taskRegisterSvcName); }