Search in sources :

Example 1 with KAFKA_HOST

use of org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_HOST in project mod-inventory by folio-org.

the class DataImportConsumerVerticle method start.

@Override
public void start(Promise<Void> startPromise) {
    JsonObject config = vertx.getOrCreateContext().config();
    KafkaConfig kafkaConfig = KafkaConfig.builder().envId(config.getString(KAFKA_ENV)).kafkaHost(config.getString(KAFKA_HOST)).kafkaPort(config.getString(KAFKA_PORT)).okapiUrl(config.getString(OKAPI_URL)).replicationFactor(Integer.parseInt(config.getString(KAFKA_REPLICATION_FACTOR))).maxRequestSize(Integer.parseInt(config.getString(KAFKA_MAX_REQUEST_SIZE))).build();
    LOGGER.info(format("kafkaConfig: %s", kafkaConfig));
    EventManager.registerKafkaEventPublisher(kafkaConfig, vertx, maxDistributionNumber);
    HttpClientOptions params = new HttpClientOptions().setConnectTimeout(DEFAULT_HTTP_TIMEOUT_IN_MILLISECONDS);
    HttpClient client = vertx.createHttpClient(params);
    Storage storage = Storage.basedUpon(vertx, config, client);
    String profileSnapshotExpirationTime = getCacheEnvVariable(config, "inventory.profile-snapshot-cache.expiration.time.seconds");
    String mappingMetadataExpirationTime = getCacheEnvVariable(config, "inventory.mapping-metadata-cache.expiration.time.seconds");
    ProfileSnapshotCache profileSnapshotCache = new ProfileSnapshotCache(vertx, client, Long.parseLong(profileSnapshotExpirationTime));
    MappingMetadataCache mappingMetadataCache = new MappingMetadataCache(vertx, client, Long.parseLong(mappingMetadataExpirationTime));
    DataImportKafkaHandler dataImportKafkaHandler = new DataImportKafkaHandler(vertx, storage, client, profileSnapshotCache, kafkaConfig, mappingMetadataCache);
    List<Future> futures = EVENT_TYPES.stream().map(eventType -> createKafkaConsumerWrapper(kafkaConfig, eventType, dataImportKafkaHandler)).collect(Collectors.toList());
    CompositeFuture.all(futures).onFailure(startPromise::fail).onSuccess(ar -> {
        futures.forEach(future -> consumerWrappers.add((KafkaConsumerWrapper<String, String>) future.result()));
        startPromise.complete();
    });
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) DI_SRS_MARC_BIB_RECORD_NOT_MATCHED(org.folio.DataImportEventTypes.DI_SRS_MARC_BIB_RECORD_NOT_MATCHED) DI_SRS_MARC_AUTHORITY_RECORD_MODIFIED_READY_FOR_POST_PROCESSING(org.folio.DataImportEventTypes.DI_SRS_MARC_AUTHORITY_RECORD_MODIFIED_READY_FOR_POST_PROCESSING) DI_INVENTORY_INSTANCE_MATCHED(org.folio.DataImportEventTypes.DI_INVENTORY_INSTANCE_MATCHED) DI_SRS_MARC_BIB_RECORD_MATCHED_READY_FOR_POST_PROCESSING(org.folio.DataImportEventTypes.DI_SRS_MARC_BIB_RECORD_MATCHED_READY_FOR_POST_PROCESSING) JsonObject(io.vertx.core.json.JsonObject) EventManager(org.folio.processing.events.EventManager) ProfileSnapshotCache(org.folio.inventory.dataimport.cache.ProfileSnapshotCache) DI_INVENTORY_INSTANCE_UPDATED(org.folio.DataImportEventTypes.DI_INVENTORY_INSTANCE_UPDATED) DI_INVENTORY_ITEM_MATCHED(org.folio.DataImportEventTypes.DI_INVENTORY_ITEM_MATCHED) Collectors(java.util.stream.Collectors) Future(io.vertx.core.Future) String.format(java.lang.String.format) DI_SRS_MARC_AUTHORITY_RECORD_NOT_MATCHED(org.folio.DataImportEventTypes.DI_SRS_MARC_AUTHORITY_RECORD_NOT_MATCHED) Storage(org.folio.inventory.storage.Storage) List(java.util.List) SubscriptionDefinition(org.folio.kafka.SubscriptionDefinition) Logger(org.apache.logging.log4j.Logger) DI_INVENTORY_INSTANCE_CREATED(org.folio.DataImportEventTypes.DI_INVENTORY_INSTANCE_CREATED) AbstractVerticle(io.vertx.core.AbstractVerticle) KAFKA_REPLICATION_FACTOR(org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_REPLICATION_FACTOR) DI_SRS_MARC_AUTHORITY_RECORD_CREATED(org.folio.DataImportEventTypes.DI_SRS_MARC_AUTHORITY_RECORD_CREATED) DI_SRS_MARC_BIB_RECORD_MODIFIED_READY_FOR_POST_PROCESSING(org.folio.DataImportEventTypes.DI_SRS_MARC_BIB_RECORD_MODIFIED_READY_FOR_POST_PROCESSING) ConsumerWrapperUtil(org.folio.inventory.dataimport.util.ConsumerWrapperUtil) HttpClient(io.vertx.core.http.HttpClient) KAFKA_MAX_REQUEST_SIZE(org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_MAX_REQUEST_SIZE) DataImportEventTypes(org.folio.DataImportEventTypes) DI_INVENTORY_HOLDING_CREATED(org.folio.DataImportEventTypes.DI_INVENTORY_HOLDING_CREATED) KafkaConsumerWrapper(org.folio.kafka.KafkaConsumerWrapper) DI_INVENTORY_HOLDING_NOT_MATCHED(org.folio.DataImportEventTypes.DI_INVENTORY_HOLDING_NOT_MATCHED) ArrayList(java.util.ArrayList) CompositeFuture(io.vertx.core.CompositeFuture) GlobalLoadSensor(org.folio.kafka.GlobalLoadSensor) DI_INVENTORY_ITEM_CREATED(org.folio.DataImportEventTypes.DI_INVENTORY_ITEM_CREATED) KAFKA_PORT(org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_PORT) KafkaTopicNameHelper(org.folio.kafka.KafkaTopicNameHelper) HttpClientOptions(io.vertx.core.http.HttpClientOptions) DI_SRS_MARC_HOLDING_RECORD_CREATED(org.folio.DataImportEventTypes.DI_SRS_MARC_HOLDING_RECORD_CREATED) Promise(io.vertx.core.Promise) DI_INVENTORY_HOLDING_MATCHED(org.folio.DataImportEventTypes.DI_INVENTORY_HOLDING_MATCHED) KAFKA_ENV(org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_ENV) DI_SRS_MARC_BIB_RECORD_CREATED(org.folio.DataImportEventTypes.DI_SRS_MARC_BIB_RECORD_CREATED) AsyncRecordHandler(org.folio.kafka.AsyncRecordHandler) DI_INVENTORY_HOLDING_UPDATED(org.folio.DataImportEventTypes.DI_INVENTORY_HOLDING_UPDATED) DI_SRS_MARC_AUTHORITY_RECORD_DELETED(org.folio.DataImportEventTypes.DI_SRS_MARC_AUTHORITY_RECORD_DELETED) DI_INVENTORY_INSTANCE_NOT_MATCHED(org.folio.DataImportEventTypes.DI_INVENTORY_INSTANCE_NOT_MATCHED) DI_SRS_MARC_BIB_RECORD_MODIFIED(org.folio.DataImportEventTypes.DI_SRS_MARC_BIB_RECORD_MODIFIED) DI_INVENTORY_ITEM_NOT_MATCHED(org.folio.DataImportEventTypes.DI_INVENTORY_ITEM_NOT_MATCHED) DI_SRS_MARC_BIB_RECORD_MATCHED(org.folio.DataImportEventTypes.DI_SRS_MARC_BIB_RECORD_MATCHED) LogManager(org.apache.logging.log4j.LogManager) KAFKA_HOST(org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_HOST) MappingMetadataCache(org.folio.inventory.dataimport.cache.MappingMetadataCache) KafkaConfig(org.folio.kafka.KafkaConfig) OKAPI_URL(org.folio.inventory.dataimport.util.KafkaConfigConstants.OKAPI_URL) DataImportKafkaHandler(org.folio.inventory.dataimport.consumers.DataImportKafkaHandler) KafkaConsumerWrapper(org.folio.kafka.KafkaConsumerWrapper) JsonObject(io.vertx.core.json.JsonObject) ProfileSnapshotCache(org.folio.inventory.dataimport.cache.ProfileSnapshotCache) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Storage(org.folio.inventory.storage.Storage) MappingMetadataCache(org.folio.inventory.dataimport.cache.MappingMetadataCache) HttpClient(io.vertx.core.http.HttpClient) Future(io.vertx.core.Future) CompositeFuture(io.vertx.core.CompositeFuture) DataImportKafkaHandler(org.folio.inventory.dataimport.consumers.DataImportKafkaHandler) KafkaConfig(org.folio.kafka.KafkaConfig)

Aggregations

AbstractVerticle (io.vertx.core.AbstractVerticle)1 CompositeFuture (io.vertx.core.CompositeFuture)1 Future (io.vertx.core.Future)1 Promise (io.vertx.core.Promise)1 HttpClient (io.vertx.core.http.HttpClient)1 HttpClientOptions (io.vertx.core.http.HttpClientOptions)1 JsonObject (io.vertx.core.json.JsonObject)1 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang.StringUtils)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 DataImportEventTypes (org.folio.DataImportEventTypes)1 DI_INVENTORY_HOLDING_CREATED (org.folio.DataImportEventTypes.DI_INVENTORY_HOLDING_CREATED)1 DI_INVENTORY_HOLDING_MATCHED (org.folio.DataImportEventTypes.DI_INVENTORY_HOLDING_MATCHED)1 DI_INVENTORY_HOLDING_NOT_MATCHED (org.folio.DataImportEventTypes.DI_INVENTORY_HOLDING_NOT_MATCHED)1 DI_INVENTORY_HOLDING_UPDATED (org.folio.DataImportEventTypes.DI_INVENTORY_HOLDING_UPDATED)1 DI_INVENTORY_INSTANCE_CREATED (org.folio.DataImportEventTypes.DI_INVENTORY_INSTANCE_CREATED)1