Skip to content

Commit

Permalink
MODINV-986: return consumers base property
Browse files Browse the repository at this point in the history
  • Loading branch information
PBobylev committed Jun 10, 2024
1 parent bac351b commit af4c9e9
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class DataImportConsumerVerticle extends KafkaConsumerVerticle {
DI_SRS_MARC_HOLDINGS_RECORD_NOT_MATCHED,
DI_PENDING_ORDER_CREATED
);
private static final String BASE_PROPERTY = "DataImportConsumerVerticle";

@Override
public void start(Promise<Void> startPromise) {
Expand All @@ -99,4 +100,9 @@ protected Logger getLogger() {
return LOGGER;
}

@Override
protected String getBaseProperty() {
return BASE_PROPERTY;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class InstanceIngressConsumerVerticle extends KafkaConsumerVerticle {

private static final String INSTANCE_INGRESS_TOPIC = "inventory.instance_ingress";
private static final Logger LOGGER = LogManager.getLogger(InstanceIngressConsumerVerticle.class);
private static final String BASE_PROPERTY = "InstanceIngressConsumerVerticle";

@Override
public void start(Promise<Void> startPromise) {
Expand All @@ -28,4 +29,9 @@ public void start(Promise<Void> startPromise) {
protected Logger getLogger() {
return LOGGER;
}

@Override
protected String getBaseProperty() {
return BASE_PROPERTY;
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/folio/inventory/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static void startConsumerVerticles(Map<String, Object> consumerVerticles
CompletableFuture<String> future6 = new CompletableFuture<>();
vertxAssistant.deployVerticle(DataImportConsumerVerticle.class.getName(),
consumerVerticlesConfig, dataImportConsumerVerticleNumber, future1);
vertxAssistant.deployVerticle(MarcBibInstanceHridSetConsumerVerticle.class.getName(),
vertxAssistant.deployVerticle(MarcHridSetConsumerVerticle.class.getName(),
consumerVerticlesConfig, instanceHridSetConsumerVerticleNumber, future2);
vertxAssistant.deployVerticle(QuickMarcConsumerVerticle.class.getName(),
consumerVerticlesConfig, quickMarcConsumerVerticleNumber, future3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class MarcBibUpdateConsumerVerticle extends KafkaConsumerVerticle {
private static final Logger LOGGER = LogManager.getLogger(MarcBibUpdateConsumerVerticle.class);
private static final String SRS_MARC_BIB_EVENT = "srs.marc-bib";
private static final String BASE_PROPERTY = "MarcBibUpdateConsumer";

@Override
public void start(Promise<Void> startPromise) {
Expand All @@ -32,4 +33,9 @@ protected Logger getLogger() {
return LOGGER;
}

@Override
protected String getBaseProperty() {
return BASE_PROPERTY;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
import org.folio.inventory.services.HoldingsCollectionService;
import org.folio.inventory.support.KafkaConsumerVerticle;

public class MarcBibInstanceHridSetConsumerVerticle extends KafkaConsumerVerticle {
public class MarcHridSetConsumerVerticle extends KafkaConsumerVerticle {

private static final Logger LOGGER = LogManager.getLogger(MarcBibInstanceHridSetConsumerVerticle.class);
private static final Logger LOGGER = LogManager.getLogger(MarcHridSetConsumerVerticle.class);
private static final String BASE_PROPERTY = "MarcBibInstanceHridSetConsumer";

@Override
public void start(Promise<Void> startPromise) {
Expand All @@ -44,4 +45,9 @@ protected Logger getLogger() {
return LOGGER;
}

@Override
protected String getBaseProperty() {
return BASE_PROPERTY;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class QuickMarcConsumerVerticle extends KafkaConsumerVerticle {

private static final Logger LOGGER = LogManager.getLogger(QuickMarcConsumerVerticle.class);
private static final String BASE_PROPERTY = "QuickMarcConsumerVerticle";

@Override
public void start(Promise<Void> startPromise) {
Expand All @@ -35,4 +36,9 @@ protected Logger getLogger() {
return LOGGER;
}

@Override
protected String getBaseProperty() {
return BASE_PROPERTY;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.Verticle;
import io.vertx.core.http.HttpClient;
import io.vertx.core.json.JsonObject;
import java.util.ArrayList;
Expand Down Expand Up @@ -157,9 +156,9 @@ private int getLoadLimit() {
}

private int getConsumerProperty(String nameTemplate, String defaultValue) {
var consumerClassName = getClass().getSimpleName();
var cleanConsumerName = consumerClassName.substring(0, consumerClassName.indexOf(Verticle.class.getSimpleName()));
return parseInt(getProperty(format(nameTemplate, cleanConsumerName), defaultValue));
return parseInt(getProperty(format(nameTemplate, getBaseProperty()), defaultValue));
}

protected abstract String getBaseProperty();

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import net.mguenther.kafka.junit.EmbeddedKafkaCluster;
import org.folio.inventory.MarcBibInstanceHridSetConsumerVerticle;
import org.folio.inventory.MarcHridSetConsumerVerticle;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -22,7 +22,7 @@
import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_REPLICATION_FACTOR;

@RunWith(VertxUnitRunner.class)
public class MarcBibInstanceHridSetConsumerVerticleTest {
public class MarcHridSetConsumerVerticleTest {

private static final String TENANT_ID = "diku";
private static final String KAFKA_ENV_NAME = "test-env";
Expand All @@ -46,7 +46,7 @@ public void shouldDeployVerticle(TestContext context) {
.setWorker(true);

Promise<String> promise = Promise.promise();
vertx.deployVerticle(MarcBibInstanceHridSetConsumerVerticle.class.getName(), options, promise);
vertx.deployVerticle(MarcHridSetConsumerVerticle.class.getName(), options, promise);

promise.future().onComplete(ar -> {
context.assertTrue(ar.succeeded());
Expand Down

0 comments on commit af4c9e9

Please sign in to comment.