Skip to content

Commit

Permalink
[MODAUD-174] - Implements kafka handler and creating table
Browse files Browse the repository at this point in the history
  • Loading branch information
azizbekxm committed Nov 10, 2023
1 parent 066fbac commit 536e9ea
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ nbproject/
.settings/
.classpath
/bin/
/src/main/resources/postgres-conf.json
12 changes: 11 additions & 1 deletion mod-audit-server/src/main/java/org/folio/rest/impl/InitAPIs.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.folio.verticle.SpringVerticleFactory;
import org.folio.verticle.acquisition.OrderEventConsumersVerticle;
import org.folio.verticle.acquisition.OrderLineEventConsumersVerticle;
import org.folio.verticle.acquisition.PieceEventConsumersVerticle;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.support.AbstractApplicationContext;

Expand All @@ -30,6 +31,8 @@ public class InitAPIs implements InitAPI {
private int acqOrderConsumerInstancesNumber;
@Value("${acq.order-lines.kafka.consumer.instancesNumber:1}")
private int acqOrderLineConsumerInstancesNumber;
@Value("${acq.pieces.kafka.consumer.instancesNumber:1}")
private int acqPieceConsumerInstancesNumber;

@Override
public void init(Vertx vertx, Context context, Handler<AsyncResult<Boolean>> handler) {
Expand Down Expand Up @@ -60,6 +63,7 @@ private Future<?> deployConsumersVerticles(Vertx vertx) {

Promise<String> orderEventsConsumer = Promise.promise();
Promise<String> orderLineEventsConsumer = Promise.promise();
Promise<String> pieceEventsConsumer = Promise.promise();

vertx.deployVerticle(getVerticleName(verticleFactory, OrderEventConsumersVerticle.class),
new DeploymentOptions()
Expand All @@ -71,10 +75,16 @@ private Future<?> deployConsumersVerticles(Vertx vertx) {
.setWorker(true)
.setInstances(acqOrderLineConsumerInstancesNumber), orderLineEventsConsumer);

vertx.deployVerticle(getVerticleName(verticleFactory, PieceEventConsumersVerticle.class),
new DeploymentOptions()
.setWorker(true)
.setInstances(acqPieceConsumerInstancesNumber), pieceEventsConsumer);

LOGGER.info("deployConsumersVerticles:: All consumer verticles were successfully deployed");
return GenericCompositeFuture.all(Arrays.asList(
orderEventsConsumer.future(),
orderLineEventsConsumer.future()));
orderLineEventsConsumer.future(),
pieceEventsConsumer.future()));
}

private <T> String getVerticleName(VerticleFactory verticleFactory, Class<T> clazz) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import org.folio.kafka.AsyncRecordHandler;
import org.folio.kafka.KafkaConfig;
import org.folio.util.AcquisitionEventType;
import org.folio.verticle.AbstractConsumersVerticle;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -11,20 +12,18 @@
@Component
public class PieceEventConsumersVerticle extends AbstractConsumersVerticle {

private final AsyncRecordHandler<String, String> orderLineEventsHandler;

@Autowired
public PieceEventConsumersVerticle(AsyncRecordHandler<String, String> orderLineEventsHandler) {
this.orderLineEventsHandler = orderLineEventsHandler;
}
private KafkaConfig kafkaConfig;
@Autowired
private AsyncRecordHandler<String, String> pieceEventsHandler;

@Override
public List<String> getEvents() {
return List.of(AcquisitionEventType.ACQ_PIECE_CHANGED.getTopicName());
return List.of(AcquisitionEventType.ACQ_ORDER_CHANGED.getTopicName());
}

@Override
public AsyncRecordHandler<String, String> getHandler() {
return orderLineEventsHandler;
return pieceEventsHandler;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
"run": "after",
"snippetPath": "acquisition/create_acquisition_order_line_log_table.sql",
"fromModuleVersion": "mod-audit-2.7.0"
},
{
"run": "after",
"snippetPath": "acquisition/create_acquisition_piece_log_table.sql",
"fromModuleVersion": "mod-audit-2.8.1"
}
]
}

0 comments on commit 536e9ea

Please sign in to comment.