use of org.eclipse.hono.notification.NotificationSender in project hono by eclipse.
the class Application method doStart.
@Override
protected void doStart() {
if (!(authenticationService instanceof Verticle)) {
throw new IllegalStateException("Authentication service must be a vert.x Verticle");
}
LOG.info("adding common tags to meter registry");
meterRegistry.config().commonTags(MetricsTags.forService(Constants.SERVICE_NAME_DEVICE_REGISTRY));
LOG.info("deploying {} {} instances ...", appConfig.getMaxInstances(), getComponentName());
final CompletableFuture<Void> startup = new CompletableFuture<>();
// deploy authentication service (once only)
final Promise<String> authServiceDeploymentTracker = Promise.promise();
vertx.deployVerticle((Verticle) authenticationService, authServiceDeploymentTracker);
// deploy notification sender (once only)
final Promise<String> notificationSenderDeploymentTracker = Promise.promise();
vertx.deployVerticle(new WrappedLifecycleComponentVerticle(notificationSender), notificationSenderDeploymentTracker);
// deploy AMQP 1.0 server
final Promise<String> amqpServerDeploymentTracker = Promise.promise();
vertx.deployVerticle(() -> amqpServerFactory.newServer(), new DeploymentOptions().setInstances(appConfig.getMaxInstances()), amqpServerDeploymentTracker);
// deploy HTTP server
final Promise<String> httpServerDeploymentTracker = Promise.promise();
vertx.deployVerticle(() -> httpServerFactory.newServer(), new DeploymentOptions().setInstances(appConfig.getMaxInstances()), httpServerDeploymentTracker);
CompositeFuture.all(authServiceDeploymentTracker.future(), notificationSenderDeploymentTracker.future(), amqpServerDeploymentTracker.future(), httpServerDeploymentTracker.future()).onSuccess(ok -> registerHealthCheckProvider(authenticationService)).compose(s -> healthCheckServer.start()).onSuccess(ok -> startup.complete(null)).onFailure(t -> startup.completeExceptionally(t));
startup.join();
}
use of org.eclipse.hono.notification.NotificationSender in project hono by eclipse.
the class Application method doStart.
@Override
protected void doStart() {
if (!(authenticationService instanceof Verticle)) {
throw new IllegalStateException("Authentication service must be a vert.x Verticle");
}
LOG.info("adding common tags to meter registry");
meterRegistry.config().commonTags(MetricsTags.forService(Constants.SERVICE_NAME_DEVICE_REGISTRY));
LOG.info("deploying {} {} instances ...", appConfig.getMaxInstances(), getComponentName());
final CompletableFuture<Void> startup = new CompletableFuture<>();
// deploy authentication service (once only)
final Promise<String> authServiceDeploymentTracker = Promise.promise();
vertx.deployVerticle((Verticle) authenticationService, authServiceDeploymentTracker);
// deploy notification sender (once only)
final Promise<String> notificationSenderDeploymentTracker = Promise.promise();
vertx.deployVerticle(new WrappedLifecycleComponentVerticle(notificationSender), notificationSenderDeploymentTracker);
// deploy AMQP 1.0 server
final Promise<String> amqpServerDeploymentTracker = Promise.promise();
vertx.deployVerticle(() -> amqpServerFactory.newServer(), new DeploymentOptions().setInstances(appConfig.getMaxInstances()), amqpServerDeploymentTracker);
// deploy HTTP server
final Promise<String> httpServerDeploymentTracker = Promise.promise();
vertx.deployVerticle(() -> httpServerFactory.newServer(), new DeploymentOptions().setInstances(appConfig.getMaxInstances()), httpServerDeploymentTracker);
CompositeFuture.all(authServiceDeploymentTracker.future(), notificationSenderDeploymentTracker.future(), amqpServerDeploymentTracker.future(), httpServerDeploymentTracker.future()).onSuccess(ok -> registerHealthCheckProvider(authenticationService)).compose(s -> healthCheckServer.start()).onSuccess(ok -> startup.complete(null)).onFailure(t -> startup.completeExceptionally(t));
startup.join();
}
use of org.eclipse.hono.notification.NotificationSender in project hono by eclipse.
the class NotificationSenderProducer method notificationSender.
@Produces
@Singleton
NotificationSender notificationSender(final Vertx vertx, final Tracer tracer, final HealthCheckServer healthCheckServer, @Named("amqp-messaging-network") final ClientConfigProperties downstreamSenderConfig, final NotificationKafkaProducerConfigProperties kafkaProducerConfig) {
final NotificationSender notificationSender;
if (kafkaProducerConfig.isConfigured()) {
notificationSender = new KafkaBasedNotificationSender(CachingKafkaProducerFactory.sharedFactory(vertx), kafkaProducerConfig);
} else {
notificationSender = new ProtonBasedNotificationSender(HonoConnection.newConnection(vertx, downstreamSenderConfig, tracer));
}
if (notificationSender instanceof ServiceClient) {
healthCheckServer.registerHealthCheckResources(ServiceClientAdapter.forClient((ServiceClient) notificationSender));
}
NotificationConstants.DEVICE_REGISTRY_NOTIFICATION_TYPES.forEach(notificationType -> {
NotificationEventBusSupport.registerConsumer(vertx, notificationType, notificationSender::publish);
});
return notificationSender;
}
use of org.eclipse.hono.notification.NotificationSender in project hono by eclipse.
the class NotificationSenderProducer method notificationSender.
@Produces
@Singleton
NotificationSender notificationSender(final Vertx vertx, final Tracer tracer, final HealthCheckServer healthCheckServer, @Named("amqp-messaging-network") final ClientConfigProperties downstreamSenderConfig, final NotificationKafkaProducerConfigProperties kafkaProducerConfig) {
final NotificationSender notificationSender;
if (kafkaProducerConfig.isConfigured()) {
notificationSender = new KafkaBasedNotificationSender(CachingKafkaProducerFactory.sharedFactory(vertx), kafkaProducerConfig);
} else {
notificationSender = new ProtonBasedNotificationSender(HonoConnection.newConnection(vertx, downstreamSenderConfig, tracer));
}
if (notificationSender instanceof ServiceClient) {
healthCheckServer.registerHealthCheckResources(ServiceClientAdapter.forClient((ServiceClient) notificationSender));
}
NotificationConstants.DEVICE_REGISTRY_NOTIFICATION_TYPES.forEach(notificationType -> {
NotificationEventBusSupport.registerConsumer(vertx, notificationType, notificationSender::publish);
});
return notificationSender;
}
use of org.eclipse.hono.notification.NotificationSender in project hono by eclipse.
the class ApplicationConfig method notificationSender.
/**
* Exposes a notification sender.
*
* @return The bean instance.
*/
@Bean
@Profile(Profiles.PROFILE_REGISTRY_MANAGEMENT)
public NotificationSender notificationSender() {
final NotificationSender notificationSender;
final var kafkaProducerConfig = notificationKafkaProducerConfig();
if (kafkaProducerConfig.isConfigured()) {
notificationSender = new KafkaBasedNotificationSender(CachingKafkaProducerFactory.sharedFactory(vertx()), kafkaProducerConfig);
} else {
notificationSender = new ProtonBasedNotificationSender(HonoConnection.newConnection(vertx(), downstreamSenderConfig(), tracer()));
}
if (notificationSender instanceof ServiceClient) {
healthCheckServer().registerHealthCheckResources(ServiceClientAdapter.forClient((ServiceClient) notificationSender));
}
NotificationConstants.DEVICE_REGISTRY_NOTIFICATION_TYPES.forEach(notificationType -> {
NotificationEventBusSupport.registerConsumer(vertx(), notificationType, notificationSender::publish);
});
return notificationSender;
}
Aggregations