Search in sources :

Example 1 with KafkaObjectFactory

use of org.apereo.cas.kafka.KafkaObjectFactory in project cas by apereo.

the class CasServicesStreamingKafkaConfiguration method registeredServiceDistributedKafkaTemplate.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public KafkaOperations<String, DistributedCacheObject<RegisteredService>> registeredServiceDistributedKafkaTemplate(final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties) {
    return BeanSupplier.of(KafkaOperations.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
        val kafka = casProperties.getServiceRegistry().getStream().getKafka();
        val mapper = new RegisteredServiceJsonSerializer().getObjectMapper();
        val factory = new KafkaObjectFactory<String, DistributedCacheObject<RegisteredService>>(kafka.getBootstrapAddress());
        return factory.getKafkaTemplate(new StringSerializer(), new JsonSerializer<>(mapper));
    }).otherwiseProxy().get();
}
Also used : lombok.val(lombok.val) KafkaObjectFactory(org.apereo.cas.kafka.KafkaObjectFactory) RegisteredService(org.apereo.cas.services.RegisteredService) RegisteredServiceJsonSerializer(org.apereo.cas.services.util.RegisteredServiceJsonSerializer) StringSerializer(org.apache.kafka.common.serialization.StringSerializer) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with KafkaObjectFactory

use of org.apereo.cas.kafka.KafkaObjectFactory in project cas by apereo.

the class CasServicesStreamingKafkaConfiguration method registeredServiceDistributedKafkaAdmin.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "registeredServiceDistributedKafkaAdmin")
public KafkaAdminOperations registeredServiceDistributedKafkaAdmin(final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties) {
    return BeanSupplier.of(KafkaAdminOperations.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
        val kafka = casProperties.getServiceRegistry().getStream().getKafka();
        val factory = new KafkaObjectFactory<String, DistributedCacheObject<RegisteredService>>(kafka.getBootstrapAddress());
        return factory.getKafkaAdmin();
    }).otherwiseProxy().get();
}
Also used : lombok.val(lombok.val) KafkaObjectFactory(org.apereo.cas.kafka.KafkaObjectFactory) RegisteredService(org.apereo.cas.services.RegisteredService) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with KafkaObjectFactory

use of org.apereo.cas.kafka.KafkaObjectFactory in project cas by apereo.

the class CasServicesStreamingKafkaConfiguration method registeredServiceKafkaListenerContainerFactory.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "registeredServiceKafkaListenerContainerFactory")
public ConcurrentKafkaListenerContainerFactory<String, DistributedCacheObject> registeredServiceKafkaListenerContainerFactory(final CasConfigurationProperties casProperties) {
    val kafka = casProperties.getServiceRegistry().getStream().getKafka();
    val factory = new KafkaObjectFactory<String, DistributedCacheObject>(kafka.getBootstrapAddress());
    factory.setConsumerGroupId("registeredServices");
    val mapper = new RegisteredServiceJsonSerializer().getObjectMapper();
    return factory.getKafkaListenerContainerFactory(new StringDeserializer(), new JsonDeserializer<>(DistributedCacheObject.class, mapper));
}
Also used : lombok.val(lombok.val) KafkaObjectFactory(org.apereo.cas.kafka.KafkaObjectFactory) RegisteredServiceJsonSerializer(org.apereo.cas.services.util.RegisteredServiceJsonSerializer) DistributedCacheObject(org.apereo.cas.util.cache.DistributedCacheObject) StringDeserializer(org.apache.kafka.common.serialization.StringDeserializer) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

lombok.val (lombok.val)3 KafkaObjectFactory (org.apereo.cas.kafka.KafkaObjectFactory)3 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)3 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)3 Bean (org.springframework.context.annotation.Bean)3 RegisteredService (org.apereo.cas.services.RegisteredService)2 RegisteredServiceJsonSerializer (org.apereo.cas.services.util.RegisteredServiceJsonSerializer)2 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)1 StringSerializer (org.apache.kafka.common.serialization.StringSerializer)1 DistributedCacheObject (org.apereo.cas.util.cache.DistributedCacheObject)1