Skip to content

Commit

Permalink
Set Threading Model to Worker
Browse files Browse the repository at this point in the history
  • Loading branch information
azizbekxm committed Sep 24, 2024
1 parent 4d53157 commit 41b6273
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/java/org/folio/rest/impl/InitAPIs.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.folio.rest.impl;

import io.vertx.core.ThreadingModel;
import java.util.Arrays;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -28,8 +29,11 @@
public class InitAPIs implements InitAPI {
private static final Logger log = LogManager.getLogger();

@Value("${kafka.consumer.verticle.instancesNumber:1}")
private int kafkaConsumersVerticleNumber;
@Value("${edi-export.consumer.verticle.instancesNumber:1}")
private int ediExportConsumersVerticleNumber;

@Value("${item.consumer.verticle.instancesNumber:1}")
private int itemConsumersVerticleNumber;

@Value("${consumer.verticle.mandatory:false}")
private boolean isConsumersVerticleMandatory;
Expand Down Expand Up @@ -75,16 +79,18 @@ private Future<?> deployKafkaConsumersVerticles(Vertx vertx) {

vertx.deployVerticle(() -> springContext.getBean(InventoryItemConsumersVerticle.class),
new DeploymentOptions()
.setThreadingModel(ThreadingModel.WORKER)
.setWorkerPoolName("inventory-item-consumers")
.setInstances(kafkaConsumersVerticleNumber), inventoryItemConsumerPromise);
.setInstances(itemConsumersVerticleNumber), inventoryItemConsumerPromise);

vertx.deployVerticle(() -> springContext.getBean(EdiExportOrdersHistoryConsumersVerticle.class),
new DeploymentOptions()
.setThreadingModel(ThreadingModel.WORKER)
.setWorkerPoolName("edi-export-orders-history-consumers")
.setInstances(kafkaConsumersVerticleNumber), ediExportOrdersHistoryConsumerPromise);
.setInstances(ediExportConsumersVerticleNumber), ediExportOrdersHistoryConsumerPromise);

return GenericCompositeFuture.all(
Arrays.asList(inventoryItemConsumerPromise.future(), ediExportOrdersHistoryConsumerPromise.future()))
Arrays.asList(inventoryItemConsumerPromise.future(), ediExportOrdersHistoryConsumerPromise.future()))
.onSuccess(ar -> log.info("All consumers was successfully started"))
.onFailure(e -> log.error("Failed to start consumers", e));
}
Expand Down

0 comments on commit 41b6273

Please sign in to comment.