diff --git a/src/main/java/it/dontesta/eventbus/consumers/events/handlers/nosql/MongoDbEventHandler.java b/src/main/java/it/dontesta/eventbus/consumers/events/handlers/nosql/MongoDbEventHandler.java index 451dc0a..8a9df75 100644 --- a/src/main/java/it/dontesta/eventbus/consumers/events/handlers/nosql/MongoDbEventHandler.java +++ b/src/main/java/it/dontesta/eventbus/consumers/events/handlers/nosql/MongoDbEventHandler.java @@ -1,5 +1,7 @@ package it.dontesta.eventbus.consumers.events.handlers.nosql; +import static it.dontesta.eventbus.application.configuration.EventHandlerAddress.*; + import io.quarkus.mongodb.reactive.ReactiveMongoClient; import io.quarkus.mongodb.reactive.ReactiveMongoCollection; import io.quarkus.runtime.ShutdownEvent; @@ -65,19 +67,17 @@ public class MongoDbEventHandler { public static final String SOURCE_COMPONENT = "source-component"; - public static final String SOURCE_VIRTUAL_ADDRESS = "nosql-trace"; + public static final String SOURCE_VIRTUAL_ADDRESS_NOSQL = "nosql-trace"; void onStart(@Observes StartupEvent ev) { - boolean existsAndEnabled = EventHandlerAddress.isAddressAndExistsEnabled( - eventHandlerAddresses, SOURCE_VIRTUAL_ADDRESS); - - if (existsAndEnabled) { + if (isAddressAndExistsEnabled( + eventHandlerAddresses, SOURCE_VIRTUAL_ADDRESS_NOSQL)) { log.debugf( "Registering the MongoDB event handler at addresses: {%s}", - SOURCE_VIRTUAL_ADDRESS); + SOURCE_VIRTUAL_ADDRESS_NOSQL); - consumer = eventBus.consumer(SOURCE_VIRTUAL_ADDRESS); + consumer = eventBus.consumer(SOURCE_VIRTUAL_ADDRESS_NOSQL); consumer.handler(this::handleEvent); } @@ -88,7 +88,7 @@ void onStop(@Observes ShutdownEvent ev) { consumer.unregisterAndAwait(); log.debugf( "Unregistering the MongoDB event handler at addresses: {%s}", - SOURCE_VIRTUAL_ADDRESS); + SOURCE_VIRTUAL_ADDRESS_NOSQL); } } diff --git a/src/main/java/it/dontesta/eventbus/consumers/events/handlers/queue/AmqpEventHandler.java b/src/main/java/it/dontesta/eventbus/consumers/events/handlers/queue/AmqpEventHandler.java index 94e3d1d..45b48c7 100644 --- a/src/main/java/it/dontesta/eventbus/consumers/events/handlers/queue/AmqpEventHandler.java +++ b/src/main/java/it/dontesta/eventbus/consumers/events/handlers/queue/AmqpEventHandler.java @@ -1,5 +1,7 @@ package it.dontesta.eventbus.consumers.events.handlers.queue; +import static it.dontesta.eventbus.application.configuration.EventHandlerAddress.isAddressAndExistsEnabled; + import io.quarkus.runtime.ShutdownEvent; import io.quarkus.runtime.StartupEvent; import io.vertx.core.json.JsonObject; @@ -57,18 +59,16 @@ public class AmqpEventHandler { public static final String SOURCE_COMPONENT = "source-component"; - public static final String SOURCE_VIRTUAL_ADDRESS = "queue-trace"; + public static final String SOURCE_VIRTUAL_ADDRESS_QUEUE = "queue-trace"; void onStart(@Observes StartupEvent ev) { - boolean existsAndEnabled = EventHandlerAddress.isAddressAndExistsEnabled( - eventHandlerAddresses, SOURCE_VIRTUAL_ADDRESS); - - if (existsAndEnabled) { + if (isAddressAndExistsEnabled( + eventHandlerAddresses, SOURCE_VIRTUAL_ADDRESS_QUEUE)) { log.debugf("Registering the AMQP event handler at addresses: {%s}", - SOURCE_VIRTUAL_ADDRESS); + SOURCE_VIRTUAL_ADDRESS_QUEUE); - consumer = eventBus.consumer(SOURCE_VIRTUAL_ADDRESS); + consumer = eventBus.consumer(SOURCE_VIRTUAL_ADDRESS_QUEUE); consumer.handler(this::handleEvent); } } @@ -77,7 +77,7 @@ void onStop(@Observes ShutdownEvent ev) { if (consumer != null) { consumer.unregisterAndAwait(); log.debugf("Unregistering the AMQP event handler at addresses: {%s}", - SOURCE_VIRTUAL_ADDRESS); + SOURCE_VIRTUAL_ADDRESS_QUEUE); } }