All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.solace.spring.cloud.stream.binder.config.SolaceHealthIndicatorsConfiguration Maven / Gradle / Ivy

The newest version!
package com.solace.spring.cloud.stream.binder.config;

import com.solace.spring.cloud.stream.binder.health.SolaceBinderHealthAccessor;
import com.solace.spring.cloud.stream.binder.health.contributors.BindingsHealthContributor;
import com.solace.spring.cloud.stream.binder.health.contributors.SolaceBinderHealthContributor;
import com.solace.spring.cloud.stream.binder.health.handlers.SolaceSessionEventHandler;
import com.solace.spring.cloud.stream.binder.health.indicators.SessionHealthIndicator;
import com.solace.spring.cloud.stream.binder.properties.SolaceSessionHealthProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
@ConditionalOnClass(name = "org.springframework.boot.actuate.health.HealthIndicator")
@ConditionalOnEnabledHealthIndicator("binders")
@EnableConfigurationProperties({SolaceSessionHealthProperties.class})
@ConditionalOnProperty(name = "solace.java.host")
public class SolaceHealthIndicatorsConfiguration {

    @Bean
    public SolaceBinderHealthAccessor solaceBinderHealthAccessor(
            SolaceBinderHealthContributor solaceBinderHealthContributor) {
        return new SolaceBinderHealthAccessor(solaceBinderHealthContributor);
    }

    @Bean
    public SolaceBinderHealthContributor solaceBinderHealthContributor(
            SolaceSessionHealthProperties solaceSessionHealthProperties) {
        if (log.isDebugEnabled()) {
            log.debug("Creating Solace Connection Health Indicators Hierarchy");
        }
        return new SolaceBinderHealthContributor(
                new SessionHealthIndicator(solaceSessionHealthProperties),
                new BindingsHealthContributor()
        );
    }

    @Bean
    public SolaceSessionEventHandler solaceSessionEventHandler(SolaceBinderHealthContributor healthContributor) {
        if (log.isDebugEnabled()) {
            log.debug("Creating Solace Session Event Handler for monitoring Health");
        }
        return new SolaceSessionEventHandler(healthContributor.getSolaceSessionHealthIndicator());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy