Search in sources :

Example 1 with ProtonBasedNotificationSender

use of org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender 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;
}
Also used : NotificationSender(org.eclipse.hono.notification.NotificationSender) ProtonBasedNotificationSender(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender) KafkaBasedNotificationSender(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationSender) KafkaBasedNotificationSender(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationSender) ServiceClient(org.eclipse.hono.client.util.ServiceClient) ProtonBasedNotificationSender(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender) Produces(javax.enterprise.inject.Produces) Singleton(javax.inject.Singleton)

Example 2 with ProtonBasedNotificationSender

use of org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender 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;
}
Also used : NotificationSender(org.eclipse.hono.notification.NotificationSender) ProtonBasedNotificationSender(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender) KafkaBasedNotificationSender(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationSender) KafkaBasedNotificationSender(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationSender) ServiceClient(org.eclipse.hono.client.util.ServiceClient) ProtonBasedNotificationSender(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender) Produces(javax.enterprise.inject.Produces) Singleton(javax.inject.Singleton)

Example 3 with ProtonBasedNotificationSender

use of org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender 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;
}
Also used : ProtonBasedNotificationSender(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender) NotificationSender(org.eclipse.hono.notification.NotificationSender) KafkaBasedNotificationSender(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationSender) KafkaBasedNotificationSender(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationSender) ServiceClient(org.eclipse.hono.client.util.ServiceClient) ProtonBasedNotificationSender(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender) Profile(org.springframework.context.annotation.Profile) ObjectFactoryCreatingFactoryBean(org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ProtonBasedNotificationSender (org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationSender)3 KafkaBasedNotificationSender (org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationSender)3 ServiceClient (org.eclipse.hono.client.util.ServiceClient)3 NotificationSender (org.eclipse.hono.notification.NotificationSender)3 Produces (javax.enterprise.inject.Produces)2 Singleton (javax.inject.Singleton)2 ObjectFactoryCreatingFactoryBean (org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean)1 Bean (org.springframework.context.annotation.Bean)1 Profile (org.springframework.context.annotation.Profile)1