Search in sources :

Example 1 with SubscriptionDefinition

use of org.folio.kafka.SubscriptionDefinition in project mod-source-record-storage by folio-org.

the class DataImportConsumersVerticle method start.

@Override
public void start(Promise<Void> startPromise) {
    context.put("springContext", springGlobalContext);
    SpringContextUtil.autowireDependencies(this, context);
    EventManager.registerKafkaEventPublisher(kafkaConfig, vertx, maxDistributionNumber);
    events.forEach(event -> {
        SubscriptionDefinition subscriptionDefinition = KafkaTopicNameHelper.createSubscriptionDefinition(kafkaConfig.getEnvId(), KafkaTopicNameHelper.getDefaultNameSpace(), event);
        consumerWrappersList.add(KafkaConsumerWrapper.<String, String>builder().context(context).vertx(vertx).kafkaConfig(kafkaConfig).loadLimit(loadLimit).globalLoadSensor(globalLoadSensor).subscriptionDefinition(subscriptionDefinition).build());
    });
    List<Future<Void>> futures = new ArrayList<>();
    consumerWrappersList.forEach(consumerWrapper -> futures.add(consumerWrapper.start(dataImportKafkaHandler, constructModuleName() + "_" + getClass().getSimpleName())));
    GenericCompositeFuture.all(futures).onComplete(ar -> startPromise.complete());
}
Also used : SubscriptionDefinition(org.folio.kafka.SubscriptionDefinition) ArrayList(java.util.ArrayList) GenericCompositeFuture(org.folio.okapi.common.GenericCompositeFuture) Future(io.vertx.core.Future)

Example 2 with SubscriptionDefinition

use of org.folio.kafka.SubscriptionDefinition in project mod-source-record-storage by folio-org.

the class QuickMarcConsumersVerticle method start.

@Override
public void start(Promise<Void> startPromise) {
    context.put("springContext", springGlobalContext);
    SpringContextUtil.autowireDependencies(this, context);
    SubscriptionDefinition subscriptionDefinition = KafkaTopicNameHelper.createSubscriptionDefinition(kafkaConfig.getEnvId(), KafkaTopicNameHelper.getDefaultNameSpace(), QMEventTypes.QM_RECORD_UPDATED.name());
    consumer = KafkaConsumerWrapper.<String, String>builder().context(context).vertx(vertx).kafkaConfig(kafkaConfig).loadLimit(loadLimit).globalLoadSensor(globalLoadSensor).subscriptionDefinition(subscriptionDefinition).build();
    consumer.start(kafkaHandler, constructModuleName() + "_" + getClass().getSimpleName()).onComplete(ar -> startPromise.complete());
}
Also used : SubscriptionDefinition(org.folio.kafka.SubscriptionDefinition)

Example 3 with SubscriptionDefinition

use of org.folio.kafka.SubscriptionDefinition in project mod-invoice by folio-org.

the class DataImportConsumerVerticle method start.

@Override
public void start(Promise<Void> startPromise) {
    context.put("springContext", springContext);
    logger.info("Kafka config: {}", kafkaConfig);
    EventManager.registerKafkaEventPublisher(kafkaConfig, vertx, maxDistributionNumber);
    SubscriptionDefinition subscriptionDefinition = KafkaTopicNameHelper.createSubscriptionDefinition(kafkaConfig.getEnvId(), KafkaTopicNameHelper.getDefaultNameSpace(), DI_EDIFACT_RECORD_CREATED.value());
    consumerWrapper = KafkaConsumerWrapper.<String, String>builder().context(context).vertx(vertx).kafkaConfig(kafkaConfig).loadLimit(loadLimit).globalLoadSensor(GLOBAL_LOAD_SENSOR).subscriptionDefinition(subscriptionDefinition).build();
    consumerWrapper.start(dataImportKafkaHandler, PomReaderUtil.INSTANCE.constructModuleVersionAndVersion(PomReaderUtil.INSTANCE.getModuleName(), PomReaderUtil.INSTANCE.getVersion())).onComplete(ar -> startPromise.handle(ar));
}
Also used : SubscriptionDefinition(org.folio.kafka.SubscriptionDefinition)

Example 4 with SubscriptionDefinition

use of org.folio.kafka.SubscriptionDefinition in project mod-inventory by folio-org.

the class DataImportConsumerVerticle method createKafkaConsumerWrapper.

private Future<KafkaConsumerWrapper<String, String>> createKafkaConsumerWrapper(KafkaConfig kafkaConfig, DataImportEventTypes eventType, AsyncRecordHandler<String, String> recordHandler) {
    SubscriptionDefinition subscriptionDefinition = KafkaTopicNameHelper.createSubscriptionDefinition(kafkaConfig.getEnvId(), KafkaTopicNameHelper.getDefaultNameSpace(), eventType.value());
    KafkaConsumerWrapper<String, String> consumerWrapper = KafkaConsumerWrapper.<String, String>builder().context(context).vertx(vertx).kafkaConfig(kafkaConfig).loadLimit(loadLimit).globalLoadSensor(new GlobalLoadSensor()).subscriptionDefinition(subscriptionDefinition).build();
    return consumerWrapper.start(recordHandler, ConsumerWrapperUtil.constructModuleName()).map(consumerWrapper);
}
Also used : GlobalLoadSensor(org.folio.kafka.GlobalLoadSensor) SubscriptionDefinition(org.folio.kafka.SubscriptionDefinition)

Example 5 with SubscriptionDefinition

use of org.folio.kafka.SubscriptionDefinition in project mod-source-record-storage by folio-org.

the class ParsedRecordChunkConsumersVerticle method start.

@Override
public void start(Promise<Void> startPromise) {
    context.put("springContext", springGlobalContext);
    SpringContextUtil.autowireDependencies(this, context);
    SubscriptionDefinition subscriptionDefinition = KafkaTopicNameHelper.createSubscriptionDefinition(kafkaConfig.getEnvId(), KafkaTopicNameHelper.getDefaultNameSpace(), DI_RAW_RECORDS_CHUNK_PARSED.value());
    consumerWrapper = KafkaConsumerWrapper.<String, String>builder().context(context).vertx(vertx).kafkaConfig(kafkaConfig).loadLimit(loadLimit).globalLoadSensor(globalLoadSensor).subscriptionDefinition(subscriptionDefinition).processRecordErrorHandler(parsedRecordChunksErrorHandler).build();
    consumerWrapper.start(parsedRecordChunksKafkaHandler, constructModuleName() + "_" + getClass().getSimpleName()).onComplete(sar -> {
        if (sar.succeeded()) {
            startPromise.complete();
        } else {
            startPromise.fail(sar.cause());
        }
    });
}
Also used : SubscriptionDefinition(org.folio.kafka.SubscriptionDefinition)

Aggregations

SubscriptionDefinition (org.folio.kafka.SubscriptionDefinition)5 Future (io.vertx.core.Future)1 ArrayList (java.util.ArrayList)1 GlobalLoadSensor (org.folio.kafka.GlobalLoadSensor)1 GenericCompositeFuture (org.folio.okapi.common.GenericCompositeFuture)1