use of org.eclipse.hono.notification.NotificationReceiver in project hono by eclipse.
the class AbstractProtocolAdapterApplication method doStart.
@Override
protected void doStart() {
LOG.info("deploying {} {} instances ...", appConfig.getMaxInstances(), getComponentName());
final CompletableFuture<Void> startup = new CompletableFuture<>();
final Future<String> adapterTracker = vertx.deployVerticle(this::adapter, new DeploymentOptions().setInstances(appConfig.getMaxInstances()));
final Future<String> notificationReceiverTracker = vertx.deployVerticle(new WrappedLifecycleComponentVerticle(notificationReceiver()));
CompositeFuture.all(adapterTracker, notificationReceiverTracker).compose(s -> healthCheckServer.start()).onSuccess(ok -> startup.complete(null)).onFailure(startup::completeExceptionally);
startup.join();
}
use of org.eclipse.hono.notification.NotificationReceiver in project hono by eclipse.
the class AbstractProtocolAdapterApplication method notificationReceiver.
/**
* Creates the notification receiver.
*
* @return The bean instance.
*/
public NotificationReceiver notificationReceiver() {
final NotificationReceiver notificationReceiver;
if (kafkaNotificationConfig.isConfigured()) {
notificationReceiver = new KafkaBasedNotificationReceiver(vertx, kafkaNotificationConfig);
} else {
final ClientConfigProperties notificationConfig = new ClientConfigProperties(downstreamSenderConfig);
notificationConfig.setServerRole("Notification");
notificationReceiver = new ProtonBasedNotificationReceiver(HonoConnection.newConnection(vertx, notificationConfig, tracer));
}
NotificationConstants.DEVICE_REGISTRY_NOTIFICATION_TYPES.forEach(notificationType -> {
notificationReceiver.registerConsumer(notificationType, notification -> {
NotificationEventBusSupport.sendNotification(vertx, notification);
});
});
return notificationReceiver;
}
use of org.eclipse.hono.notification.NotificationReceiver in project hono by eclipse.
the class Application method notificationReceiver.
/**
* Creates the notification receiver.
*
* @return The bean instance.
*/
public NotificationReceiver notificationReceiver() {
final NotificationReceiver notificationReceiver;
if (kafkaNotificationConfig.isConfigured()) {
notificationReceiver = new KafkaBasedNotificationReceiver(vertx, kafkaNotificationConfig);
} else {
final ClientConfigProperties notificationConfig = new ClientConfigProperties(commandConsumerConnectionConfig);
notificationConfig.setServerRole("Notification");
notificationReceiver = new ProtonBasedNotificationReceiver(HonoConnection.newConnection(vertx, notificationConfig, tracer));
}
NotificationConstants.DEVICE_REGISTRY_NOTIFICATION_TYPES.forEach(notificationType -> {
notificationReceiver.registerConsumer(notificationType, notification -> {
NotificationEventBusSupport.sendNotification(vertx, notification);
});
});
return notificationReceiver;
}
use of org.eclipse.hono.notification.NotificationReceiver 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("deploying {} {} instances ...", appConfig.getMaxInstances(), getComponentName());
final CompletableFuture<Void> startup = new CompletableFuture<>();
// deploy authentication service (once only)
final Future<String> authServiceDeploymentTracker = vertx.deployVerticle((Verticle) authenticationService).onSuccess(ok -> registerHealthCheckProvider(authenticationService));
// deploy AMQP 1.0 server
final Future<String> amqpServerDeploymentTracker = vertx.deployVerticle(this::amqpServer, new DeploymentOptions().setInstances(appConfig.getMaxInstances()));
// deploy notification receiver
final Future<String> notificationReceiverTracker = vertx.deployVerticle(new WrappedLifecycleComponentVerticle(notificationReceiver()));
CompositeFuture.all(authServiceDeploymentTracker, amqpServerDeploymentTracker, notificationReceiverTracker).compose(s -> healthCheckServer.start()).onSuccess(ok -> startup.complete(null)).onFailure(startup::completeExceptionally);
startup.join();
}
Aggregations