Search in sources :

Example 1 with MessageHistoryConfigurer

use of org.springframework.integration.history.MessageHistoryConfigurer in project spring-integration by spring-projects.

the class IntegrationMBeanExporter method afterSingletonsInstantiated.

@Override
public void afterSingletonsInstantiated() {
    Map<String, MessageHandlerMetrics> messageHandlers = this.applicationContext.getBeansOfType(MessageHandlerMetrics.class);
    for (Entry<String, MessageHandlerMetrics> entry : messageHandlers.entrySet()) {
        String beanName = entry.getKey();
        MessageHandlerMetrics bean = entry.getValue();
        if (this.handlerInAnonymousWrapper(bean) != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("Skipping " + beanName + " because it wraps another handler");
            }
            continue;
        }
        // If the handler is proxied, we have to extract the target to expose as an MBean.
        // The MetadataMBeanInfoAssembler does not support JDK dynamic proxies.
        MessageHandlerMetrics monitor = (MessageHandlerMetrics) extractTarget(bean);
        this.handlers.add(monitor);
    }
    Map<String, MessageSourceMetrics> messageSources = this.applicationContext.getBeansOfType(MessageSourceMetrics.class);
    for (Entry<String, MessageSourceMetrics> entry : messageSources.entrySet()) {
        // If the source is proxied, we have to extract the target to expose as an MBean.
        // The MetadataMBeanInfoAssembler does not support JDK dynamic proxies.
        MessageSourceMetrics monitor = (MessageSourceMetrics) extractTarget(entry.getValue());
        this.sources.add(monitor);
    }
    Map<String, MessageChannelMetrics> messageChannels = this.applicationContext.getBeansOfType(MessageChannelMetrics.class);
    for (Entry<String, MessageChannelMetrics> entry : messageChannels.entrySet()) {
        // If the channel is proxied, we have to extract the target to expose as an MBean.
        // The MetadataMBeanInfoAssembler does not support JDK dynamic proxies.
        MessageChannelMetrics monitor = (MessageChannelMetrics) extractTarget(entry.getValue());
        this.channels.add(monitor);
    }
    Map<String, MessageProducer> messageProducers = this.applicationContext.getBeansOfType(MessageProducer.class);
    for (Entry<String, MessageProducer> entry : messageProducers.entrySet()) {
        MessageProducer messageProducer = entry.getValue();
        if (messageProducer instanceof Lifecycle) {
            Lifecycle target = (Lifecycle) extractTarget(messageProducer);
            if (!(target instanceof AbstractMessageProducingHandler)) {
                this.inboundLifecycleMessageProducers.add(target);
            }
        }
    }
    super.afterSingletonsInstantiated();
    try {
        registerChannels();
        registerHandlers();
        registerSources();
        registerEndpoints();
        if (this.applicationContext.containsBean(IntegrationContextUtils.INTEGRATION_MESSAGE_HISTORY_CONFIGURER_BEAN_NAME)) {
            Object messageHistoryConfigurer = this.applicationContext.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_HISTORY_CONFIGURER_BEAN_NAME);
            if (messageHistoryConfigurer instanceof MessageHistoryConfigurer) {
                registerBeanInstance(messageHistoryConfigurer, IntegrationContextUtils.INTEGRATION_MESSAGE_HISTORY_CONFIGURER_BEAN_NAME);
            }
        }
        if (!this.applicationContext.containsBean(IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME)) {
            this.managementConfigurer = new IntegrationManagementConfigurer();
            this.managementConfigurer.setDefaultCountsEnabled(true);
            this.managementConfigurer.setDefaultStatsEnabled(true);
            this.managementConfigurer.setApplicationContext(this.applicationContext);
            this.managementConfigurer.setBeanName(IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME);
            this.managementConfigurer.afterSingletonsInstantiated();
        } else {
            this.managementConfigurer = this.applicationContext.getBean(IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME, IntegrationManagementConfigurer.class);
        }
    } catch (RuntimeException e) {
        unregisterBeans();
        throw e;
    }
}
Also used : IntegrationManagementConfigurer(org.springframework.integration.config.IntegrationManagementConfigurer) MessageChannelMetrics(org.springframework.integration.support.management.MessageChannelMetrics) MessageSourceMetrics(org.springframework.integration.support.management.MessageSourceMetrics) LifecycleTrackableMessageSourceMetrics(org.springframework.integration.support.management.LifecycleTrackableMessageSourceMetrics) LifecycleMessageSourceMetrics(org.springframework.integration.support.management.LifecycleMessageSourceMetrics) MessageHistoryConfigurer(org.springframework.integration.history.MessageHistoryConfigurer) Lifecycle(org.springframework.context.Lifecycle) LifecycleTrackableMessageHandlerMetrics(org.springframework.integration.support.management.LifecycleTrackableMessageHandlerMetrics) LifecycleMessageHandlerMetrics(org.springframework.integration.support.management.LifecycleMessageHandlerMetrics) MessageHandlerMetrics(org.springframework.integration.support.management.MessageHandlerMetrics) AbstractMessageProducingHandler(org.springframework.integration.handler.AbstractMessageProducingHandler) MessageProducer(org.springframework.integration.core.MessageProducer)

Aggregations

Lifecycle (org.springframework.context.Lifecycle)1 IntegrationManagementConfigurer (org.springframework.integration.config.IntegrationManagementConfigurer)1 MessageProducer (org.springframework.integration.core.MessageProducer)1 AbstractMessageProducingHandler (org.springframework.integration.handler.AbstractMessageProducingHandler)1 MessageHistoryConfigurer (org.springframework.integration.history.MessageHistoryConfigurer)1 LifecycleMessageHandlerMetrics (org.springframework.integration.support.management.LifecycleMessageHandlerMetrics)1 LifecycleMessageSourceMetrics (org.springframework.integration.support.management.LifecycleMessageSourceMetrics)1 LifecycleTrackableMessageHandlerMetrics (org.springframework.integration.support.management.LifecycleTrackableMessageHandlerMetrics)1 LifecycleTrackableMessageSourceMetrics (org.springframework.integration.support.management.LifecycleTrackableMessageSourceMetrics)1 MessageChannelMetrics (org.springframework.integration.support.management.MessageChannelMetrics)1 MessageHandlerMetrics (org.springframework.integration.support.management.MessageHandlerMetrics)1 MessageSourceMetrics (org.springframework.integration.support.management.MessageSourceMetrics)1