Search in sources :

Example 1 with NotificationReceiver

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();
}
Also used : WebClientOptions(io.vertx.ext.web.client.WebClientOptions) MessagingKafkaConsumerConfigProperties(org.eclipse.hono.client.kafka.consumer.MessagingKafkaConsumerConfigProperties) MessagingKafkaProducerConfigProperties(org.eclipse.hono.client.kafka.producer.MessagingKafkaProducerConfigProperties) ProtonBasedDeviceRegistrationClient(org.eclipse.hono.client.registry.amqp.ProtonBasedDeviceRegistrationClient) KafkaBasedEventSender(org.eclipse.hono.client.telemetry.kafka.KafkaBasedEventSender) KafkaBasedCommandResponseSender(org.eclipse.hono.client.command.kafka.KafkaBasedCommandResponseSender) LoggerFactory(org.slf4j.LoggerFactory) LoggingConnectionEventProducer(org.eclipse.hono.adapter.monitoring.LoggingConnectionEventProducer) CommandRouterCommandConsumerFactory(org.eclipse.hono.client.command.CommandRouterCommandConsumerFactory) PrometheusBasedResourceLimitChecksConfig(org.eclipse.hono.adapter.resourcelimits.PrometheusBasedResourceLimitChecksConfig) KafkaAdminClientOptions(org.eclipse.hono.client.kafka.KafkaAdminClientOptions) NoopResourceLimitChecks(org.eclipse.hono.adapter.resourcelimits.NoopResourceLimitChecks) AbstractServiceApplication(org.eclipse.hono.service.quarkus.AbstractServiceApplication) TelemetrySender(org.eclipse.hono.client.telemetry.TelemetrySender) ProtonBasedInternalCommandConsumer(org.eclipse.hono.client.command.amqp.ProtonBasedInternalCommandConsumer) MessagingType(org.eclipse.hono.util.MessagingType) Duration(java.time.Duration) CredentialsClient(org.eclipse.hono.client.registry.CredentialsClient) RegistrationResult(org.eclipse.hono.util.RegistrationResult) DataVolumeAsyncCacheLoader(org.eclipse.hono.adapter.resourcelimits.DataVolumeAsyncCacheLoader) ClientConfigProperties(org.eclipse.hono.config.ClientConfigProperties) ProtonBasedCredentialsClient(org.eclipse.hono.client.registry.amqp.ProtonBasedCredentialsClient) KafkaConsumerOptions(org.eclipse.hono.client.kafka.consumer.KafkaConsumerOptions) NotificationConstants(org.eclipse.hono.notification.NotificationConstants) ConnectionEventProducerConfig(org.eclipse.hono.adapter.monitoring.ConnectionEventProducerConfig) MessagingClientProviders(org.eclipse.hono.adapter.MessagingClientProviders) EventSender(org.eclipse.hono.client.telemetry.EventSender) CredentialsResult(org.eclipse.hono.util.CredentialsResult) ProtonBasedNotificationReceiver(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationReceiver) CachingKafkaProducerFactory(org.eclipse.hono.client.kafka.producer.CachingKafkaProducerFactory) TenantClient(org.eclipse.hono.client.registry.TenantClient) Caches(org.eclipse.hono.service.cache.Caches) Future(io.vertx.core.Future) Executors(java.util.concurrent.Executors) Objects(java.util.Objects) ConfigMapping(io.smallrye.config.ConfigMapping) List(java.util.List) KafkaProducerFactory(org.eclipse.hono.client.kafka.producer.KafkaProducerFactory) ConnectionDurationAsyncCacheLoader(org.eclipse.hono.adapter.resourcelimits.ConnectionDurationAsyncCacheLoader) Buffer(io.vertx.core.buffer.Buffer) CommandRouterClient(org.eclipse.hono.client.command.CommandRouterClient) Optional(java.util.Optional) MicrometerKafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.MicrometerKafkaClientMetricsSupport) ConnectionEventProducerOptions(org.eclipse.hono.adapter.monitoring.ConnectionEventProducerOptions) NotificationEventBusSupport(org.eclipse.hono.notification.NotificationEventBusSupport) KafkaBasedTelemetrySender(org.eclipse.hono.client.telemetry.kafka.KafkaBasedTelemetrySender) WebClient(io.vertx.ext.web.client.WebClient) ProtonBasedCommandResponseSender(org.eclipse.hono.client.command.amqp.ProtonBasedCommandResponseSender) ProtonBasedTenantClient(org.eclipse.hono.client.registry.amqp.ProtonBasedTenantClient) CompletableFuture(java.util.concurrent.CompletableFuture) ConnectionEventProducer(org.eclipse.hono.adapter.monitoring.ConnectionEventProducer) ClientOptions(org.eclipse.hono.config.quarkus.ClientOptions) Cache(com.github.benmanes.caffeine.cache.Cache) CommandResponseSender(org.eclipse.hono.client.command.CommandResponseSender) Inject(javax.inject.Inject) CompositeFuture(io.vertx.core.CompositeFuture) CommonKafkaClientOptions(org.eclipse.hono.client.kafka.CommonKafkaClientOptions) KafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.KafkaClientMetricsSupport) KafkaBasedInternalCommandConsumer(org.eclipse.hono.client.command.kafka.KafkaBasedInternalCommandConsumer) KafkaMetricsOptions(org.eclipse.hono.client.kafka.metrics.KafkaMetricsOptions) DeviceRegistrationClient(org.eclipse.hono.client.registry.DeviceRegistrationClient) PrometheusBasedResourceLimitCheckOptions(org.eclipse.hono.adapter.resourcelimits.PrometheusBasedResourceLimitCheckOptions) KafkaAdminClientConfigProperties(org.eclipse.hono.client.kafka.KafkaAdminClientConfigProperties) PrometheusBasedResourceLimitChecks(org.eclipse.hono.adapter.resourcelimits.PrometheusBasedResourceLimitChecks) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) HonoConnection(org.eclipse.hono.client.HonoConnection) ProtonBasedCommandRouterClient(org.eclipse.hono.client.command.amqp.ProtonBasedCommandRouterClient) RequestResponseClientConfigProperties(org.eclipse.hono.client.RequestResponseClientConfigProperties) NotificationReceiver(org.eclipse.hono.notification.NotificationReceiver) NotificationKafkaConsumerConfigProperties(org.eclipse.hono.client.notification.kafka.NotificationKafkaConsumerConfigProperties) ProtocolAdapterProperties(org.eclipse.hono.config.ProtocolAdapterProperties) TenantResult(org.eclipse.hono.util.TenantResult) Caffeine(com.github.benmanes.caffeine.cache.Caffeine) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) AbstractProtocolAdapterBase(org.eclipse.hono.adapter.AbstractProtocolAdapterBase) MessagingClientProvider(org.eclipse.hono.client.util.MessagingClientProvider) KafkaBasedNotificationReceiver(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationReceiver) KafkaProducerOptions(org.eclipse.hono.client.kafka.producer.KafkaProducerOptions) RequestResponseClientOptions(org.eclipse.hono.client.RequestResponseClientOptions) TenantObject(org.eclipse.hono.util.TenantObject) NoopKafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.NoopKafkaClientMetricsSupport) DeploymentOptions(io.vertx.core.DeploymentOptions) ProtonBasedDownstreamSender(org.eclipse.hono.client.telemetry.amqp.ProtonBasedDownstreamSender) ResourceLimitChecks(org.eclipse.hono.adapter.resourcelimits.ResourceLimitChecks) ConnectedDevicesAsyncCacheLoader(org.eclipse.hono.adapter.resourcelimits.ConnectedDevicesAsyncCacheLoader) SendMessageSampler(org.eclipse.hono.client.SendMessageSampler) HonoEventConnectionEventProducer(org.eclipse.hono.adapter.monitoring.HonoEventConnectionEventProducer) CredentialsObject(org.eclipse.hono.util.CredentialsObject) CompletableFuture(java.util.concurrent.CompletableFuture) DeploymentOptions(io.vertx.core.DeploymentOptions) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle)

Example 2 with NotificationReceiver

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;
}
Also used : KafkaBasedNotificationReceiver(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationReceiver) ProtonBasedNotificationReceiver(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationReceiver) NotificationReceiver(org.eclipse.hono.notification.NotificationReceiver) KafkaBasedNotificationReceiver(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationReceiver) ClientConfigProperties(org.eclipse.hono.config.ClientConfigProperties) KafkaAdminClientConfigProperties(org.eclipse.hono.client.kafka.KafkaAdminClientConfigProperties) RequestResponseClientConfigProperties(org.eclipse.hono.client.RequestResponseClientConfigProperties) ProtonBasedNotificationReceiver(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationReceiver)

Example 3 with 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;
}
Also used : KafkaBasedNotificationReceiver(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationReceiver) ProtonBasedNotificationReceiver(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationReceiver) NotificationReceiver(org.eclipse.hono.notification.NotificationReceiver) KafkaBasedNotificationReceiver(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationReceiver) ClientConfigProperties(org.eclipse.hono.config.ClientConfigProperties) KafkaAdminClientConfigProperties(org.eclipse.hono.client.kafka.KafkaAdminClientConfigProperties) RequestResponseClientConfigProperties(org.eclipse.hono.client.RequestResponseClientConfigProperties) ProtonBasedNotificationReceiver(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationReceiver)

Example 4 with 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();
}
Also used : MessagingKafkaConsumerConfigProperties(org.eclipse.hono.client.kafka.consumer.MessagingKafkaConsumerConfigProperties) MessagingKafkaProducerConfigProperties(org.eclipse.hono.client.kafka.producer.MessagingKafkaProducerConfigProperties) ProtonBasedDeviceRegistrationClient(org.eclipse.hono.client.registry.amqp.ProtonBasedDeviceRegistrationClient) CommandRouterService(org.eclipse.hono.service.commandrouter.CommandRouterService) LoggerFactory(org.slf4j.LoggerFactory) Watcher(io.fabric8.kubernetes.client.Watcher) ServiceConfigProperties(org.eclipse.hono.config.ServiceConfigProperties) KafkaAdminClientOptions(org.eclipse.hono.client.kafka.KafkaAdminClientOptions) AbstractServiceApplication(org.eclipse.hono.service.quarkus.AbstractServiceApplication) RegistrationResult(org.eclipse.hono.util.RegistrationResult) ProtonSaslAuthenticatorFactory(io.vertx.proton.sasl.ProtonSaslAuthenticatorFactory) ClientConfigProperties(org.eclipse.hono.config.ClientConfigProperties) KafkaConsumerOptions(org.eclipse.hono.client.kafka.consumer.KafkaConsumerOptions) ProtonBasedCommandConsumerFactoryImpl(org.eclipse.hono.commandrouter.impl.amqp.ProtonBasedCommandConsumerFactoryImpl) NotificationConstants(org.eclipse.hono.notification.NotificationConstants) ProtonBasedNotificationReceiver(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationReceiver) CachingKafkaProducerFactory(org.eclipse.hono.client.kafka.producer.CachingKafkaProducerFactory) CommandRouterServiceImpl(org.eclipse.hono.commandrouter.impl.CommandRouterServiceImpl) CommandTargetMapper(org.eclipse.hono.commandrouter.CommandTargetMapper) TenantClient(org.eclipse.hono.client.registry.TenantClient) KafkaBasedCommandConsumerFactoryImpl(org.eclipse.hono.commandrouter.impl.kafka.KafkaBasedCommandConsumerFactoryImpl) Caches(org.eclipse.hono.service.cache.Caches) Future(io.vertx.core.Future) DeviceConnectionInfo(org.eclipse.hono.deviceconnection.infinispan.client.DeviceConnectionInfo) ConfigMapping(io.smallrye.config.ConfigMapping) List(java.util.List) KafkaProducerFactory(org.eclipse.hono.client.kafka.producer.KafkaProducerFactory) Buffer(io.vertx.core.buffer.Buffer) ServiceOptions(org.eclipse.hono.config.quarkus.ServiceOptions) MicrometerKafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.MicrometerKafkaClientMetricsSupport) ApplicationScoped(javax.enterprise.context.ApplicationScoped) NotificationEventBusSupport(org.eclipse.hono.notification.NotificationEventBusSupport) AdapterInstanceStatusService(org.eclipse.hono.commandrouter.AdapterInstanceStatusService) CommandRouterAmqpServer(org.eclipse.hono.commandrouter.CommandRouterAmqpServer) ProtonBasedTenantClient(org.eclipse.hono.client.registry.amqp.ProtonBasedTenantClient) CompletableFuture(java.util.concurrent.CompletableFuture) ClientOptions(org.eclipse.hono.config.quarkus.ClientOptions) Cache(com.github.benmanes.caffeine.cache.Cache) InternalKafkaTopicCleanupService(org.eclipse.hono.commandrouter.impl.kafka.InternalKafkaTopicCleanupService) Inject(javax.inject.Inject) WatcherException(io.fabric8.kubernetes.client.WatcherException) CompositeFuture(io.vertx.core.CompositeFuture) CommonKafkaClientOptions(org.eclipse.hono.client.kafka.CommonKafkaClientOptions) HealthCheckHandler(io.vertx.ext.healthchecks.HealthCheckHandler) KafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.KafkaClientMetricsSupport) KafkaMetricsOptions(org.eclipse.hono.client.kafka.metrics.KafkaMetricsOptions) DeviceRegistrationClient(org.eclipse.hono.client.registry.DeviceRegistrationClient) HealthCheckProvider(org.eclipse.hono.service.HealthCheckProvider) KafkaAdminClientConfigProperties(org.eclipse.hono.client.kafka.KafkaAdminClientConfigProperties) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) HonoConnection(org.eclipse.hono.client.HonoConnection) DelegatingCommandRouterAmqpEndpoint(org.eclipse.hono.service.commandrouter.DelegatingCommandRouterAmqpEndpoint) RequestResponseClientConfigProperties(org.eclipse.hono.client.RequestResponseClientConfigProperties) NotificationReceiver(org.eclipse.hono.notification.NotificationReceiver) NotificationKafkaConsumerConfigProperties(org.eclipse.hono.client.notification.kafka.NotificationKafkaConsumerConfigProperties) TenantResult(org.eclipse.hono.util.TenantResult) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) MessagingClientProvider(org.eclipse.hono.client.util.MessagingClientProvider) KafkaBasedNotificationReceiver(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationReceiver) AuthenticationService(org.eclipse.hono.service.auth.AuthenticationService) KafkaProducerOptions(org.eclipse.hono.client.kafka.producer.KafkaProducerOptions) Pod(io.fabric8.kubernetes.api.model.Pod) Verticle(io.vertx.core.Verticle) RequestResponseClientOptions(org.eclipse.hono.client.RequestResponseClientOptions) TenantObject(org.eclipse.hono.util.TenantObject) NoopKafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.NoopKafkaClientMetricsSupport) CommandRouterMetrics(org.eclipse.hono.commandrouter.CommandRouterMetrics) DeploymentOptions(io.vertx.core.DeploymentOptions) AmqpEndpoint(org.eclipse.hono.service.amqp.AmqpEndpoint) CommandConsumerFactory(org.eclipse.hono.commandrouter.CommandConsumerFactory) SendMessageSampler(org.eclipse.hono.client.SendMessageSampler) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) Verticle(io.vertx.core.Verticle) CompletableFuture(java.util.concurrent.CompletableFuture) DeploymentOptions(io.vertx.core.DeploymentOptions) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle)

Aggregations

RequestResponseClientConfigProperties (org.eclipse.hono.client.RequestResponseClientConfigProperties)4 KafkaAdminClientConfigProperties (org.eclipse.hono.client.kafka.KafkaAdminClientConfigProperties)4 ProtonBasedNotificationReceiver (org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationReceiver)4 KafkaBasedNotificationReceiver (org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationReceiver)4 ClientConfigProperties (org.eclipse.hono.config.ClientConfigProperties)4 NotificationReceiver (org.eclipse.hono.notification.NotificationReceiver)4 Cache (com.github.benmanes.caffeine.cache.Cache)2 Tracer (io.opentracing.Tracer)2 ConfigMapping (io.smallrye.config.ConfigMapping)2 CompositeFuture (io.vertx.core.CompositeFuture)2 DeploymentOptions (io.vertx.core.DeploymentOptions)2 Future (io.vertx.core.Future)2 Buffer (io.vertx.core.buffer.Buffer)2 List (java.util.List)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Inject (javax.inject.Inject)2 HonoConnection (org.eclipse.hono.client.HonoConnection)2 RequestResponseClientOptions (org.eclipse.hono.client.RequestResponseClientOptions)2 Caffeine (com.github.benmanes.caffeine.cache.Caffeine)1 Pod (io.fabric8.kubernetes.api.model.Pod)1