diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java index 9f4b52e589..7c67be533b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java @@ -32,7 +32,6 @@ import org.aopalliance.aop.Advice; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.beans.factory.DisposableBean; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.context.Lifecycle; @@ -92,7 +91,7 @@ import org.springframework.util.CollectionUtils; * @since 2.0 */ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageProducingHandler - implements DiscardingMessageHandler, DisposableBean, ApplicationEventPublisherAware, Lifecycle { + implements DiscardingMessageHandler, ApplicationEventPublisherAware, Lifecycle { private final Comparator> sequenceNumberComparator = new MessageSequenceComparator(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageGroupProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageGroupProcessor.java index 6e1b9ee0c4..709bea3929 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageGroupProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageGroupProcessor.java @@ -19,7 +19,6 @@ package org.springframework.integration.aggregator; import java.util.Map; import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.core.convert.ConversionService; import org.springframework.integration.store.MessageGroup; @@ -32,7 +31,7 @@ import org.springframework.integration.store.MessageGroup; * @author Dave Syer * @author Gary Russell */ -public class ExpressionEvaluatingMessageGroupProcessor extends AbstractAggregatingMessageGroupProcessor implements BeanFactoryAware { +public class ExpressionEvaluatingMessageGroupProcessor extends AbstractAggregatingMessageGroupProcessor { private final ExpressionEvaluatingMessageListProcessor processor; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java index 5565d944dc..560fa34b28 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java @@ -37,9 +37,6 @@ import org.springframework.integration.support.management.AbstractMessageChannel import org.springframework.integration.support.management.ConfigurableMetricsAware; import org.springframework.integration.support.management.DefaultMessageChannelMetrics; import org.springframework.integration.support.management.IntegrationManagedResource; -import org.springframework.integration.support.management.MessageChannelMetrics; -import org.springframework.integration.support.management.MetricsContext; -import org.springframework.integration.support.management.Statistics; import org.springframework.integration.support.management.TrackableComponent; import org.springframework.integration.support.management.metrics.MeterFacade; import org.springframework.integration.support.management.metrics.MetricsCaptor; @@ -69,7 +66,8 @@ import org.springframework.util.StringUtils; @IntegrationManagedResource @SuppressWarnings("deprecation") public abstract class AbstractMessageChannel extends IntegrationObjectSupport - implements MessageChannel, TrackableComponent, ChannelInterceptorAware, MessageChannelMetrics, + implements MessageChannel, TrackableComponent, ChannelInterceptorAware, + org.springframework.integration.support.management.MessageChannelMetrics, ConfigurableMetricsAware { protected final ChannelInterceptorList interceptors; // NOSONAR @@ -117,8 +115,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport } @Override - public void registerMetricsCaptor(MetricsCaptor metricsCaptor) { - this.metricsCaptor = metricsCaptor; + public void registerMetricsCaptor(MetricsCaptor metricsCaptorToRegister) { + this.metricsCaptor = metricsCaptorToRegister; } @Nullable @@ -335,17 +333,17 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport } @Override - public Statistics getSendDuration() { + public org.springframework.integration.support.management.Statistics getSendDuration() { return this.channelMetrics.getSendDuration(); } @Override - public Statistics getSendRate() { + public org.springframework.integration.support.management.Statistics getSendRate() { return this.channelMetrics.getSendRate(); } @Override - public Statistics getErrorRate() { + public org.springframework.integration.support.management.Statistics getErrorRate() { return this.channelMetrics.getErrorRate(); } @@ -429,7 +427,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport Deque interceptorStack = null; boolean sent = false; boolean metricsProcessed = false; - MetricsContext metricsContext = null; + org.springframework.integration.support.management.MetricsContext metricsContext = null; boolean countsAreEnabled = this.countsEnabled; ChannelInterceptorList interceptorList = this.interceptors; AbstractMessageChannelMetrics metrics = this.channelMetrics; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java index cead87e005..21c45bb150 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java @@ -27,8 +27,6 @@ import org.springframework.integration.support.management.AbstractMessageChannel import org.springframework.integration.support.management.ConfigurableMetricsAware; import org.springframework.integration.support.management.DefaultMessageChannelMetrics; import org.springframework.integration.support.management.IntegrationManagedResource; -import org.springframework.integration.support.management.MessageChannelMetrics; -import org.springframework.integration.support.management.Statistics; import org.springframework.integration.support.management.metrics.MetricsCaptor; import org.springframework.integration.support.management.metrics.TimerFacade; import org.springframework.lang.Nullable; @@ -47,7 +45,9 @@ import org.springframework.util.Assert; * @author Artyem Bilan */ @IntegrationManagedResource -public class NullChannel implements PollableChannel, MessageChannelMetrics, +@SuppressWarnings("deprecation") +public class NullChannel implements PollableChannel, + org.springframework.integration.support.management.MessageChannelMetrics, ConfigurableMetricsAware, BeanNameAware, NamedComponent { private final Log logger = LogFactory.getLog(getClass()); @@ -211,17 +211,17 @@ public class NullChannel implements PollableChannel, MessageChannelMetrics, } @Override - public Statistics getSendDuration() { + public org.springframework.integration.support.management.Statistics getSendDuration() { return this.channelMetrics.getSendDuration(); } @Override - public Statistics getSendRate() { + public org.springframework.integration.support.management.Statistics getSendRate() { return this.channelMetrics.getSendRate(); } @Override - public Statistics getErrorRate() { + public org.springframework.integration.support.management.Statistics getErrorRate() { return this.channelMetrics.getErrorRate(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ThreadStatePropagationChannelInterceptor.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ThreadStatePropagationChannelInterceptor.java index b7afa60e6c..a4f1ff8795 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ThreadStatePropagationChannelInterceptor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ThreadStatePropagationChannelInterceptor.java @@ -21,7 +21,6 @@ import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageHandler; import org.springframework.messaging.MessageHeaders; -import org.springframework.messaging.support.ChannelInterceptor; import org.springframework.messaging.support.ExecutorChannelInterceptor; /** @@ -51,7 +50,7 @@ import org.springframework.messaging.support.ExecutorChannelInterceptor; * @since 4.2 */ public abstract class ThreadStatePropagationChannelInterceptor - implements ChannelInterceptor, ExecutorChannelInterceptor { + implements ExecutorChannelInterceptor { @Override public final Message preSend(Message message, MessageChannel channel) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/EnableIntegrationManagement.java b/spring-integration-core/src/main/java/org/springframework/integration/config/EnableIntegrationManagement.java index 49179aa6ed..bd30a54e47 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/EnableIntegrationManagement.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/EnableIntegrationManagement.java @@ -23,6 +23,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.context.annotation.Import; +import org.springframework.core.annotation.AliasFor; /** * Enables default configuring of management in Spring Integration components in an existing application. @@ -53,9 +54,29 @@ public @interface EnableIntegrationManagement { * Defaults to no components, unless JMX is enabled in which case, defaults to all * components. Overrides {@link #defaultCountsEnabled()} for matching bean names. * @return the patterns. + * @deprecated in favor of 'metersEnabled'. */ + @Deprecated + @AliasFor("metersEnabled") String[] countsEnabled() default "*"; + /** + * A list of simple patterns for component names for which message counts will be + * enabled (defaults to '*'). Enables message + * counting (`sendCount`, `errorCount`, `receiveCount`) for those components that + * support counters (channels, message handlers, etc). This is the initial setting + * only, individual components can have counts enabled/disabled at runtime. May be + * overridden by an entry in {@link #statsEnabled() statsEnabled} which is additional + * functionality over simple counts. If a pattern starts with `!`, counts are disabled + * for matches. For components that match multiple patterns, the first pattern wins. + * Disabling counts at runtime also disables stats. + * Defaults to no components, unless JMX is enabled in which case, defaults to all + * components. Overrides {@link #defaultCountsEnabled()} for matching bean names. + * @return the patterns. + */ + @AliasFor("countsEnabled") + String[] metersEnabled() default "*"; + /** * A list of simple patterns for component names for which message statistics will be * enabled (response times, rates etc), as well as counts (a positive match here @@ -72,7 +93,11 @@ public @interface EnableIntegrationManagement { * Defaults to no components, unless JMX is enabled in which case, defaults to all * components. * @return the patterns. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. */ + @Deprecated String[] statsEnabled() default "*"; /** @@ -86,7 +111,11 @@ public @interface EnableIntegrationManagement { * The default setting for enabling statistics when a bean name is not matched by * {@link #statsEnabled() statsEnabled}. * @return the value; false by default, or true when JMX is enabled. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. */ + @Deprecated String defaultStatsEnabled() default "false"; /** @@ -113,7 +142,11 @@ public @interface EnableIntegrationManagement { * The bean name of a {@code MetricsFactory}. The {@code DefaultMetricsFactory} is used * if omitted. * @return the bean name. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. */ + @Deprecated String metricsFactory() default ""; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfiguration.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfiguration.java index 68f62a2a2e..4d22082d71 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfiguration.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfiguration.java @@ -64,6 +64,7 @@ public class IntegrationManagementConfiguration implements ImportAware, Environm "@EnableIntegrationManagement is not present on importing class " + importMetadata.getClassName()); } + @SuppressWarnings("deprecation") @Bean(name = IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public IntegrationManagementConfigurer managementConfigurer() { @@ -90,17 +91,18 @@ public class IntegrationManagementConfiguration implements ImportAware, Environm String pattern = this.environment.resolvePlaceholders(managedComponent); patterns.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(pattern))); } - configurer.setEnabledCountsPatterns(patterns.toArray(new String[patterns.size()])); + configurer.setEnabledCountsPatterns(patterns.toArray(new String[0])); } + @SuppressWarnings("deprecation") private void setupStatsEnabledNamePatterns(IntegrationManagementConfigurer configurer) { - List patterns = new ArrayList(); + List patterns = new ArrayList<>(); String[] statsEnabled = this.attributes.getStringArray("statsEnabled"); for (String managedComponent : statsEnabled) { String pattern = this.environment.resolvePlaceholders(managedComponent); patterns.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(pattern))); } - configurer.setEnabledStatsPatterns(patterns.toArray(new String[patterns.size()])); + configurer.setEnabledStatsPatterns(patterns.toArray(new String[0])); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfigurer.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfigurer.java index ae1e8a5bd1..ccfb5ef0a5 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfigurer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfigurer.java @@ -34,14 +34,8 @@ import org.springframework.integration.core.MessageSource; import org.springframework.integration.support.management.AbstractMessageChannelMetrics; import org.springframework.integration.support.management.AbstractMessageHandlerMetrics; import org.springframework.integration.support.management.ConfigurableMetricsAware; -import org.springframework.integration.support.management.DefaultMetricsFactory; import org.springframework.integration.support.management.IntegrationManagement; import org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides; -import org.springframework.integration.support.management.MessageChannelMetrics; -import org.springframework.integration.support.management.MessageHandlerMetrics; -import org.springframework.integration.support.management.MessageSourceMetrics; -import org.springframework.integration.support.management.MessageSourceMetricsConfigurer; -import org.springframework.integration.support.management.MetricsFactory; import org.springframework.integration.support.management.PollableChannelManagement; import org.springframework.integration.support.management.metrics.MetricsCaptor; import org.springframework.integration.support.management.micrometer.MicrometerMetricsCaptor; @@ -64,6 +58,7 @@ import org.springframework.util.StringUtils; * @since 4.2 * */ +@SuppressWarnings("deprecation") public class IntegrationManagementConfigurer implements SmartInitializingSingleton, ApplicationContextAware, BeanNameAware, DestructionAwareBeanPostProcessor { @@ -72,13 +67,18 @@ public class IntegrationManagementConfigurer public static final String MANAGEMENT_CONFIGURER_NAME = "integrationManagementConfigurer"; - private final Map channelsByName = new HashMap<>(); + private final Map + channelsByName = new HashMap<>(); - private final Map handlersByName = new HashMap<>(); + private final Map + handlersByName = new HashMap<>(); - private final Map sourcesByName = new HashMap<>(); + private final Map + sourcesByName = new HashMap<>(); - private final Map sourceConfigurers = new HashMap<>(); + private final Map + sourceConfigurers = new HashMap<>(); private ApplicationContext applicationContext; @@ -90,7 +90,7 @@ public class IntegrationManagementConfigurer private Boolean defaultStatsEnabled = false; - private MetricsFactory metricsFactory; + private org.springframework.integration.support.management.MetricsFactory metricsFactory; private String metricsFactoryBeanName; @@ -115,11 +115,15 @@ public class IntegrationManagementConfigurer /** * Set a metrics factory. * Has a precedence over {@link #metricsFactoryBeanName}. - * Defaults to {@link DefaultMetricsFactory}. + * Defaults to {@link org.springframework.integration.support.management.DefaultMetricsFactory}. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @param metricsFactory the factory. * @since 4.2 */ - public void setMetricsFactory(MetricsFactory metricsFactory) { + @Deprecated + public void setMetricsFactory(org.springframework.integration.support.management.MetricsFactory metricsFactory) { this.metricsFactory = metricsFactory; } @@ -127,8 +131,12 @@ public class IntegrationManagementConfigurer * Set a metrics factory bean name. * Is used if {@link #metricsFactory} isn't specified. * @param metricsFactory the factory. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @since 4.2 */ + @Deprecated public void setMetricsFactoryBeanName(String metricsFactory) { this.metricsFactoryBeanName = metricsFactory; } @@ -164,8 +172,12 @@ public class IntegrationManagementConfigurer * 'foo' in {@link #setEnabledCountsPatterns(String[]) enabledCountsPatterns}. For * components that match multiple patterns, the first pattern wins. Enabling stats at * runtime also enables counts. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @param enabledStatsPatterns the patterns. */ + @Deprecated public void setEnabledStatsPatterns(String[] enabledStatsPatterns) { Assert.notEmpty(enabledStatsPatterns, "enabledStatsPatterns must not be empty"); this.enabledStatsPatterns = Arrays.copyOf(enabledStatsPatterns, enabledStatsPatterns.length); @@ -188,11 +200,23 @@ public class IntegrationManagementConfigurer * Set whether managed components maintain message statistics by default. * Defaults to false, unless an Integration MBean Exporter is configured. * @param defaultStatsEnabled true to enable. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. */ + @Deprecated public void setDefaultStatsEnabled(Boolean defaultStatsEnabled) { this.defaultStatsEnabled = defaultStatsEnabled; } + /** + * Return true if stats are enabled by default. + * @return the stats enabled. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. + */ + @Deprecated public Boolean getDefaultStatsEnabled() { return this.defaultStatsEnabled; } @@ -234,18 +258,22 @@ public class IntegrationManagementConfigurer registerComponentGauges(); } if (this.metricsFactory == null && StringUtils.hasText(this.metricsFactoryBeanName)) { - this.metricsFactory = this.applicationContext.getBean(this.metricsFactoryBeanName, MetricsFactory.class); + this.metricsFactory = this.applicationContext.getBean(this.metricsFactoryBeanName, + org.springframework.integration.support.management.MetricsFactory.class); } if (this.metricsFactory == null) { - Map factories = this.applicationContext.getBeansOfType(MetricsFactory.class); + Map + factories = this.applicationContext + .getBeansOfType(org.springframework.integration.support.management.MetricsFactory.class); if (factories.size() == 1) { this.metricsFactory = factories.values().iterator().next(); } } if (this.metricsFactory == null) { - this.metricsFactory = new DefaultMetricsFactory(); + this.metricsFactory = new org.springframework.integration.support.management.DefaultMetricsFactory(); } - this.sourceConfigurers.putAll(this.applicationContext.getBeansOfType(MessageSourceMetricsConfigurer.class)); + this.sourceConfigurers.putAll(this.applicationContext.getBeansOfType( + org.springframework.integration.support.management.MessageSourceMetricsConfigurer.class)); Map managed = this.applicationContext .getBeansOfType(IntegrationManagement.class); for (Entry entry : managed.entrySet()) { @@ -284,44 +312,47 @@ public class IntegrationManagementConfigurer @Override public boolean requiresDestruction(Object bean) { - return bean instanceof MessageChannelMetrics || - bean instanceof MessageHandlerMetrics || - bean instanceof MessageSourceMetrics; + return bean instanceof org.springframework.integration.support.management.MessageChannelMetrics || + bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics || + bean instanceof org.springframework.integration.support.management.MessageSourceMetrics; } @Override - public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException { - if (bean instanceof MessageChannelMetrics) { - this.channelsByName.remove(beanName); + public void postProcessBeforeDestruction(Object bean, String nameOfBean) throws BeansException { + if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) { + this.channelsByName.remove(nameOfBean); } - else if (bean instanceof MessageHandlerMetrics) { - if (this.handlersByName.remove(beanName) == null) { - this.handlersByName.remove(beanName + ".handler"); + else if (bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics) { + if (this.handlersByName.remove(nameOfBean) == null) { + this.handlersByName.remove(nameOfBean + ".handler"); } } - else if (bean instanceof MessageSourceMetrics) { - if (this.sourcesByName.remove(beanName) == null) { - this.sourcesByName.remove(beanName + ".source"); + else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics) { + if (this.sourcesByName.remove(nameOfBean) == null) { + this.sourcesByName.remove(nameOfBean + ".source"); } } } private Object doConfigureMetrics(Object bean, String name) { - if (bean instanceof MessageChannelMetrics) { - configureChannelMetrics(name, (MessageChannelMetrics) bean); + if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) { + configureChannelMetrics(name, (org.springframework.integration.support.management.MessageChannelMetrics) bean); } - else if (bean instanceof MessageHandlerMetrics) { - configureHandlerMetrics(name, (MessageHandlerMetrics) bean); + else if (bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics) { + configureHandlerMetrics(name, (org.springframework.integration.support.management.MessageHandlerMetrics) bean); } - else if (bean instanceof MessageSourceMetrics) { - configureSourceMetrics(name, (MessageSourceMetrics) bean); - this.sourceConfigurers.values().forEach(c -> c.configure((MessageSourceMetrics) bean, name)); + else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics) { + configureSourceMetrics(name, (org.springframework.integration.support.management.MessageSourceMetrics) bean); + this.sourceConfigurers.values().forEach(c -> c + .configure((org.springframework.integration.support.management.MessageSourceMetrics) bean, name)); } return bean; } @SuppressWarnings("unchecked") - private void configureChannelMetrics(String name, MessageChannelMetrics bean) { + private void configureChannelMetrics(String name, + org.springframework.integration.support.management.MessageChannelMetrics bean) { + AbstractMessageChannelMetrics metrics; if (bean instanceof PollableChannelManagement) { metrics = this.metricsFactory.createPollableChannelMetrics(name); @@ -358,7 +389,8 @@ public class IntegrationManagementConfigurer } @SuppressWarnings("unchecked") - private void configureHandlerMetrics(String name, MessageHandlerMetrics bean) { + private void configureHandlerMetrics(String name, + org.springframework.integration.support.management.MessageHandlerMetrics bean) { AbstractMessageHandlerMetrics metrics = this.metricsFactory.createHandlerMetrics(name); Assert.state(metrics != null, "'metrics' must not be null"); ManagementOverrides overrides = bean.getOverrides(); @@ -389,7 +421,9 @@ public class IntegrationManagementConfigurer this.handlersByName.put(bean.getManagedName() != null ? bean.getManagedName() : name, bean); } - private void configureSourceMetrics(String name, MessageSourceMetrics bean) { + private void configureSourceMetrics(String name, + org.springframework.integration.support.management.MessageSourceMetrics bean) { + Boolean enabled = PatternMatchUtils.smartMatch(name, this.enabledCountsPatterns); if (enabled != null) { bean.setCountsEnabled(enabled); @@ -420,18 +454,18 @@ public class IntegrationManagementConfigurer } public String[] getChannelNames() { - return this.channelsByName.keySet().toArray(new String[this.channelsByName.size()]); + return this.channelsByName.keySet().toArray(new String[0]); } public String[] getHandlerNames() { - return this.handlersByName.keySet().toArray(new String[this.handlersByName.size()]); + return this.handlersByName.keySet().toArray(new String[0]); } public String[] getSourceNames() { - return this.sourcesByName.keySet().toArray(new String[this.sourcesByName.size()]); + return this.sourcesByName.keySet().toArray(new String[0]); } - public MessageChannelMetrics getChannelMetrics(String name) { + public org.springframework.integration.support.management.MessageChannelMetrics getChannelMetrics(String name) { if (this.channelsByName.containsKey(name)) { return this.channelsByName.get(name); } @@ -441,7 +475,7 @@ public class IntegrationManagementConfigurer return null; } - public MessageHandlerMetrics getHandlerMetrics(String name) { + public org.springframework.integration.support.management.MessageHandlerMetrics getHandlerMetrics(String name) { if (this.handlersByName.containsKey(name)) { return this.handlersByName.get(name); } @@ -455,7 +489,7 @@ public class IntegrationManagementConfigurer return null; } - public MessageSourceMetrics getSourceMetrics(String name) { + public org.springframework.integration.support.management.MessageSourceMetrics getSourceMetrics(String name) { if (this.sourcesByName.containsKey(name)) { return this.sourcesByName.get(name); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java index 6b61dd6346..6d7e269c8b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java @@ -42,8 +42,7 @@ import org.springframework.util.StringUtils; * @since 5.0 */ public final class RouterSpec - extends AbstractRouterSpec, R> - implements ComponentsRegistration { + extends AbstractRouterSpec, R> { private final RouterMappingProvider mappingProvider; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractMessageSource.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractMessageSource.java index 92a0030b0f..cb123c394f 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractMessageSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractMessageSource.java @@ -27,7 +27,6 @@ import org.springframework.integration.expression.ExpressionEvalMap; import org.springframework.integration.support.AbstractIntegrationMessageBuilder; import org.springframework.integration.support.context.NamedComponent; import org.springframework.integration.support.management.IntegrationManagedResource; -import org.springframework.integration.support.management.MessageSourceMetrics; import org.springframework.integration.support.management.metrics.CounterFacade; import org.springframework.integration.support.management.metrics.MetricsCaptor; import org.springframework.integration.util.AbstractExpressionEvaluator; @@ -43,9 +42,11 @@ import org.springframework.util.CollectionUtils; * * @since 2.0 */ +@SuppressWarnings("deprecation") @IntegrationManagedResource public abstract class AbstractMessageSource extends AbstractExpressionEvaluator - implements MessageSource, MessageSourceMetrics, NamedComponent, BeanNameAware { + implements MessageSource, org.springframework.integration.support.management.MessageSourceMetrics, + NamedComponent, BeanNameAware { private final AtomicLong messageCount = new AtomicLong(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java index 764d076db2..92251a4183 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java @@ -18,7 +18,6 @@ package org.springframework.integration.endpoint; import java.lang.reflect.Method; -import org.springframework.beans.factory.InitializingBean; import org.springframework.context.Lifecycle; import org.springframework.messaging.MessagingException; import org.springframework.util.Assert; @@ -32,8 +31,7 @@ import org.springframework.util.ReflectionUtils; * @author Gary Russell * @author Artem Bilan */ -public class MethodInvokingMessageSource extends AbstractMessageSource - implements InitializingBean, Lifecycle { +public class MethodInvokingMessageSource extends AbstractMessageSource implements Lifecycle { private volatile Object object; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/PollingConsumer.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/PollingConsumer.java index 0bd305c8f2..fb543b1136 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/PollingConsumer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/PollingConsumer.java @@ -70,7 +70,7 @@ public class PollingConsumer extends AbstractPollingEndpoint implements Integrat this.inputChannel = inputChannel; this.handler = handler; if (this.inputChannel instanceof ExecutorChannelInterceptorAware) { - this.channelInterceptors = ((ExecutorChannelInterceptorAware) this.inputChannel).getChannelInterceptors(); + this.channelInterceptors = ((ExecutorChannelInterceptorAware) this.inputChannel).getInterceptors(); } else { this.channelInterceptors = null; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/MessagingGatewaySupport.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/MessagingGatewaySupport.java index 5df95b94fa..79174e273d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/MessagingGatewaySupport.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/MessagingGatewaySupport.java @@ -44,8 +44,6 @@ import org.springframework.integration.support.MessageBuilderFactory; import org.springframework.integration.support.MutableMessageBuilder; import org.springframework.integration.support.converter.SimpleMessageConverter; import org.springframework.integration.support.management.IntegrationManagedResource; -import org.springframework.integration.support.management.MessageSourceMetrics; -import org.springframework.integration.support.management.TrackableComponent; import org.springframework.lang.Nullable; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -71,9 +69,11 @@ import reactor.core.publisher.Mono; * @author Gary Russell * @author Artem Bilan */ +@SuppressWarnings("deprecation") @IntegrationManagedResource public abstract class MessagingGatewaySupport extends AbstractEndpoint - implements TrackableComponent, MessageSourceMetrics { + implements org.springframework.integration.support.management.TrackableComponent, + org.springframework.integration.support.management.MessageSourceMetrics { private static final long DEFAULT_TIMEOUT = 1000L; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageChannelNode.java b/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageChannelNode.java index c2e5c79ebf..00a3ef7f60 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageChannelNode.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageChannelNode.java @@ -16,8 +16,6 @@ package org.springframework.integration.graph; -import org.springframework.integration.support.management.MessageChannelMetrics; -import org.springframework.integration.support.management.Statistics; import org.springframework.messaging.MessageChannel; /** @@ -28,19 +26,22 @@ import org.springframework.messaging.MessageChannel; * @since 4.3 * */ +@SuppressWarnings("deprecation") public class MessageChannelNode extends IntegrationNode { public MessageChannelNode(int nodeId, String name, MessageChannel channel) { - super(nodeId, name, channel, channel instanceof MessageChannelMetrics - ? new Stats((MessageChannelMetrics) channel) : new IntegrationNode.Stats()); + super(nodeId, name, channel, + channel instanceof org.springframework.integration.support.management.MessageChannelMetrics + ? new Stats((org.springframework.integration.support.management.MessageChannelMetrics) channel) + : new IntegrationNode.Stats()); } public static final class Stats extends IntegrationNode.Stats { - private final MessageChannelMetrics channel; + private final org.springframework.integration.support.management.MessageChannelMetrics channel; - Stats(MessageChannelMetrics channel) { + Stats(org.springframework.integration.support.management.MessageChannelMetrics channel) { this.channel = channel; } @@ -97,15 +98,15 @@ public class MessageChannelNode extends IntegrationNode { return this.channel.getStandardDeviationSendDuration(); } - public Statistics getSendDuration() { + public org.springframework.integration.support.management.Statistics getSendDuration() { return this.channel.getSendDuration(); } - public Statistics getSendRate() { + public org.springframework.integration.support.management.Statistics getSendRate() { return this.channel.getSendRate(); } - public Statistics getErrorRate() { + public org.springframework.integration.support.management.Statistics getErrorRate() { return this.channel.getErrorRate(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageHandlerNode.java b/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageHandlerNode.java index 73736c57b8..61bf961328 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageHandlerNode.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageHandlerNode.java @@ -16,8 +16,6 @@ package org.springframework.integration.graph; -import org.springframework.integration.support.management.MessageHandlerMetrics; -import org.springframework.integration.support.management.Statistics; import org.springframework.messaging.MessageHandler; /** @@ -28,13 +26,16 @@ import org.springframework.messaging.MessageHandler; * @since 4.3 * */ +@SuppressWarnings("deprecation") public class MessageHandlerNode extends EndpointNode { private final String input; public MessageHandlerNode(int nodeId, String name, MessageHandler handler, String input, String output) { - super(nodeId, name, handler, output, handler instanceof MessageHandlerMetrics - ? new Stats((MessageHandlerMetrics) handler) : new IntegrationNode.Stats()); + super(nodeId, name, handler, output, + handler instanceof org.springframework.integration.support.management.MessageHandlerMetrics + ? new Stats((org.springframework.integration.support.management.MessageHandlerMetrics) handler) + : new IntegrationNode.Stats()); this.input = input; } @@ -44,9 +45,9 @@ public class MessageHandlerNode extends EndpointNode { public static final class Stats extends IntegrationNode.Stats { - private final MessageHandlerMetrics handler; + private final org.springframework.integration.support.management.MessageHandlerMetrics handler; - Stats(MessageHandlerMetrics handler) { + Stats(org.springframework.integration.support.management.MessageHandlerMetrics handler) { this.handler = handler; } @@ -87,7 +88,7 @@ public class MessageHandlerNode extends EndpointNode { return this.handler.getActiveCountLong(); } - public Statistics getDuration() { + public org.springframework.integration.support.management.Statistics getDuration() { return this.handler.getDuration(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageSourceNode.java b/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageSourceNode.java index f6e45c5756..13931ffa7a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageSourceNode.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/graph/MessageSourceNode.java @@ -17,7 +17,6 @@ package org.springframework.integration.graph; import org.springframework.integration.core.MessageSource; -import org.springframework.integration.support.management.MessageSourceMetrics; /** * Represents a message source. @@ -27,19 +26,23 @@ import org.springframework.integration.support.management.MessageSourceMetrics; * @since 4.3 * */ +@SuppressWarnings("deprecation") public class MessageSourceNode extends ErrorCapableEndpointNode { public MessageSourceNode(int nodeId, String name, MessageSource messageSource, String output, String errors) { - super(nodeId, name, messageSource, output, errors, messageSource instanceof MessageSourceMetrics - ? new Stats((MessageSourceMetrics) messageSource) : new IntegrationNode.Stats()); + super(nodeId, name, messageSource, output, errors, + messageSource instanceof org.springframework.integration.support.management.MessageSourceMetrics + ? new Stats( + (org.springframework.integration.support.management.MessageSourceMetrics) messageSource) + : new IntegrationNode.Stats()); } public static final class Stats extends IntegrationNode.Stats { - private final MessageSourceMetrics source; + private final org.springframework.integration.support.management.MessageSourceMetrics source; - Stats(MessageSourceMetrics source) { + Stats(org.springframework.integration.support.management.MessageSourceMetrics source) { this.source = source; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageHandler.java index c2fcf407bd..fd44c546da 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageHandler.java @@ -29,9 +29,6 @@ import org.springframework.integration.support.management.AbstractMessageHandler import org.springframework.integration.support.management.ConfigurableMetricsAware; import org.springframework.integration.support.management.DefaultMessageHandlerMetrics; import org.springframework.integration.support.management.IntegrationManagedResource; -import org.springframework.integration.support.management.MessageHandlerMetrics; -import org.springframework.integration.support.management.MetricsContext; -import org.springframework.integration.support.management.Statistics; import org.springframework.integration.support.management.TrackableComponent; import org.springframework.integration.support.management.metrics.MeterFacade; import org.springframework.integration.support.management.metrics.MetricsCaptor; @@ -55,9 +52,12 @@ import reactor.core.CoreSubscriber; * @author Gary Russell * @author Artem Bilan */ +@SuppressWarnings("deprecation") @IntegrationManagedResource public abstract class AbstractMessageHandler extends IntegrationObjectSupport - implements MessageHandler, MessageHandlerMetrics, ConfigurableMetricsAware, + implements MessageHandler, + org.springframework.integration.support.management.MessageHandlerMetrics, + ConfigurableMetricsAware, TrackableComponent, Orderable, CoreSubscriber> { private final ManagementOverrides managementOverrides = new ManagementOverrides(); @@ -147,7 +147,7 @@ public abstract class AbstractMessageHandler extends IntegrationObjectSupport if (this.loggingEnabled && this.logger.isDebugEnabled()) { this.logger.debug(this + " received message: " + message); } - MetricsContext start = null; + org.springframework.integration.support.management.MetricsContext start = null; boolean countsAreEnabled = this.countsEnabled; AbstractMessageHandlerMetrics metrics = this.handlerMetrics; SampleFacade sample = null; @@ -280,7 +280,7 @@ public abstract class AbstractMessageHandler extends IntegrationObjectSupport } @Override - public Statistics getDuration() { + public org.springframework.integration.support.management.Statistics getDuration() { return this.handlerMetrics.getDuration(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java b/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java index d93cf8bdc3..add8be0fb8 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java @@ -19,7 +19,6 @@ package org.springframework.integration.resource; import java.util.Arrays; import java.util.Collection; -import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.core.io.Resource; @@ -44,7 +43,7 @@ import org.springframework.util.ObjectUtils; * @since 2.1 */ public class ResourceRetrievingMessageSource extends AbstractMessageSource - implements ApplicationContextAware, InitializingBean { + implements ApplicationContextAware { private final String pattern; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java index db01c9474c..aec62d9973 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java @@ -30,7 +30,6 @@ import java.util.stream.Collectors; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.beans.factory.InitializingBean; import org.springframework.integration.core.MessageSelector; import org.springframework.integration.filter.ExpressionEvaluatingSelector; import org.springframework.jmx.export.annotation.ManagedAttribute; @@ -73,8 +72,7 @@ import org.springframework.util.StringUtils; * @author Liujiong * @author Gary Russell */ -public class RecipientListRouter extends AbstractMessageRouter - implements InitializingBean, RecipientListRouterManagement { +public class RecipientListRouter extends AbstractMessageRouter implements RecipientListRouterManagement { private volatile Queue recipients = new ConcurrentLinkedQueue<>(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/AbstractMessageChannelMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/AbstractMessageChannelMetrics.java index 14cb8a17ae..32e1e14fcc 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/AbstractMessageChannelMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/AbstractMessageChannelMetrics.java @@ -61,6 +61,7 @@ public abstract class AbstractMessageChannelMetrics implements ConfigurableMetri * @return the context to be used in a subsequent {@link #afterSend(MetricsContext, boolean)} * call. */ + @SuppressWarnings("deprecation") public abstract MetricsContext beforeSend(); /** @@ -70,7 +71,7 @@ public abstract class AbstractMessageChannelMetrics implements ConfigurableMetri * @param context the context. * @param result true for success, false otherwise. */ - public abstract void afterSend(MetricsContext context, boolean result); + public abstract void afterSend(@SuppressWarnings("deprecation") MetricsContext context, boolean result); /** * Reset all counters/statistics. @@ -101,10 +102,13 @@ public abstract class AbstractMessageChannelMetrics implements ConfigurableMetri public abstract double getStandardDeviationSendDuration(); + @SuppressWarnings("deprecation") public abstract Statistics getSendDuration(); + @SuppressWarnings("deprecation") public abstract Statistics getSendRate(); + @SuppressWarnings("deprecation") public abstract Statistics getErrorRate(); public abstract void afterReceive(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/AbstractMessageHandlerMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/AbstractMessageHandlerMetrics.java index 4bfed02469..4b3c8dda6d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/AbstractMessageHandlerMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/AbstractMessageHandlerMetrics.java @@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory; * @since 4.2 * */ +@SuppressWarnings("deprecation") public abstract class AbstractMessageHandlerMetrics implements ConfigurableMetrics { protected final Log logger = LogFactory.getLog(getClass()); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMessageChannelMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMessageChannelMetrics.java index e0f1046861..f40a6fff81 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMessageChannelMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMessageChannelMetrics.java @@ -24,6 +24,7 @@ package org.springframework.integration.support.management; * @author Gary Russell * @since 4.2 */ +@SuppressWarnings("deprecation") public class AggregatingMessageChannelMetrics extends DefaultMessageChannelMetrics { private static final int DEFAULT_SAMPLE_SIZE = 1000; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMessageHandlerMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMessageHandlerMetrics.java index d9cdc8d78d..6086077626 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMessageHandlerMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMessageHandlerMetrics.java @@ -25,6 +25,7 @@ package org.springframework.integration.support.management; * @author Gary Russell * @since 4.2 */ +@SuppressWarnings("deprecation") public class AggregatingMessageHandlerMetrics extends DefaultMessageHandlerMetrics { private static final int DEFAULT_SAMPLE_SIZE = 1000; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMetricsFactory.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMetricsFactory.java index 5781fee641..42459bc07c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMetricsFactory.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/AggregatingMetricsFactory.java @@ -16,16 +16,18 @@ package org.springframework.integration.support.management; - - - /** * Implementation that returns aggregating metrics. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * * @author Gary Russell * @since 4.2 * */ +@Deprecated +@SuppressWarnings("deprecation") public class AggregatingMetricsFactory implements MetricsFactory { private final int sampleSize; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/BaseChannelMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/BaseChannelMetrics.java new file mode 100644 index 0000000000..bfc4cdda0a --- /dev/null +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/BaseChannelMetrics.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.support.management; + +import org.springframework.jmx.export.annotation.ManagedMetric; +import org.springframework.jmx.support.MetricType; + +/** + * Primary interface for channels that provide metrics. + * + * @author Gary Russell + * @since 5.2 + * + */ +public interface BaseChannelMetrics extends IntegrationStatsManagement { + + /** + * @return the number of successful sends + */ + @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Send Count") + long sendCount(); + + /** + * @return the number of failed sends (either throwing an exception or rejected by the channel) + */ + @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Send Error Count") + long sendErrorCount(); + +} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/BaseHandlerMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/BaseHandlerMetrics.java new file mode 100644 index 0000000000..c51005e7a2 --- /dev/null +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/BaseHandlerMetrics.java @@ -0,0 +1,41 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.support.management; + +import org.springframework.jmx.export.annotation.ManagedMetric; +import org.springframework.jmx.support.MetricType; + +/** + * @author Gary Russell + * @since 5.2 + * + */ +public interface BaseHandlerMetrics extends IntegrationStatsManagement { + + /** + * @return the number of successful handler calls + */ + @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Execution Count") + long handleCount(); + + /** + * @return the number of failed handler calls + */ + @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Error Count") + long errorCount(); + +} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/BaseSourceMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/BaseSourceMetrics.java new file mode 100644 index 0000000000..d58badff82 --- /dev/null +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/BaseSourceMetrics.java @@ -0,0 +1,32 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.support.management; + +/** + * @author Gary Russell + * @since 5.2 + * + */ +public interface BaseSourceMetrics extends IntegrationManagement { + + /** + * The number of successful message receptions. + * @return the count. + */ + long messageCount(); + +} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMessageChannelMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMessageChannelMetrics.java index 4b7b5f6a1b..7339df87a9 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMessageChannelMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMessageChannelMetrics.java @@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicLong; * * @since 2.0 */ +@SuppressWarnings("deprecation") public class DefaultMessageChannelMetrics extends AbstractMessageChannelMetrics { public static final long ONE_SECOND_SECONDS = 1; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMessageHandlerMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMessageHandlerMetrics.java index 4a6a95f45c..6d2086f72d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMessageHandlerMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMessageHandlerMetrics.java @@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicLong; * @author Gary Russell * @since 2.0 */ +@SuppressWarnings("deprecation") public class DefaultMessageHandlerMetrics extends AbstractMessageHandlerMetrics { private static final int DEFAULT_MOVING_AVERAGE_WINDOW = 10; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMetricsFactory.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMetricsFactory.java index 7f748b73d3..083c3f273b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMetricsFactory.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/DefaultMetricsFactory.java @@ -21,11 +21,16 @@ package org.springframework.integration.support.management; /** * Default implementation. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * * @author Gary Russell * @since 4.2 * */ +@Deprecated +@SuppressWarnings("deprecation") public class DefaultMetricsFactory implements MetricsFactory { @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverage.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverage.java index 13ec5db537..6b447490ff 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverage.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverage.java @@ -32,11 +32,16 @@ import java.util.List; * those trends can be approximately reflected. For performance reasons, the calculation is performed on retrieval, * {@code window * 5} samples are retained meaning that the earliest retained value contributes just 0.5% to the * sum. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * * @author Dave Syer * @author Gary Russell * @since 2.0 */ +@Deprecated +@SuppressWarnings("deprecation") public class ExponentialMovingAverage { private volatile long count; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRate.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRate.java index e7e6fcaecf..af42e7e688 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRate.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRate.java @@ -37,11 +37,16 @@ import java.util.List; * For performance reasons, the calculation is performed on retrieval, * {@code window * 5} samples are retained meaning that the earliest retained value contributes just 0.5% to the * sum. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @author Dave Syer * @author Gary Russell * @author Steven Swor * */ +@Deprecated +@SuppressWarnings("deprecation") public class ExponentialMovingAverageRate { private volatile double min = Double.MAX_VALUE; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRatio.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRatio.java index 2e28c4b4b9..97ed91711b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRatio.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRatio.java @@ -38,11 +38,16 @@ import java.util.List; * For performance reasons, the calculation is performed on retrieval, * {@code window * 5} samples are retained meaning that the earliest retained value contributes just 0.5% to the * sum. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @author Dave Syer * @author Gary Russell * @author Steven Swor * @since 2.0 */ +@Deprecated +@SuppressWarnings("deprecation") public class ExponentialMovingAverageRatio { private volatile double t0; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageHandlerMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageHandlerMetrics.java index be532516da..bdd6408735 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageHandlerMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageHandlerMetrics.java @@ -21,23 +21,32 @@ import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedOperation; /** - * A {@link MessageHandlerMetrics} that exposes in addition the {@link Lifecycle} interface. The lifecycle methods can - * be used to stop and start polling endpoints, for instance, in a live system. + * A {@link MessageHandlerMetrics} that exposes in addition the {@link Lifecycle} + * interface. The lifecycle methods can be used to stop and start polling endpoints, for + * instance, in a live system. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * * @author Dave Syer * @author Gary Russell * @since 2.0 */ +@Deprecated @IntegrationManagedResource -public class LifecycleMessageHandlerMetrics implements MessageHandlerMetrics, Lifecycle, - ConfigurableMetricsAware { +@SuppressWarnings("deprecation") +public class LifecycleMessageHandlerMetrics implements + org.springframework.integration.support.management.MessageHandlerMetrics, Lifecycle, + ConfigurableMetricsAware { private final Lifecycle lifecycle; - protected final MessageHandlerMetrics delegate; + protected final org.springframework.integration.support.management.MessageHandlerMetrics delegate; - public LifecycleMessageHandlerMetrics(Lifecycle lifecycle, MessageHandlerMetrics delegate) { + public LifecycleMessageHandlerMetrics(Lifecycle lifecycle, + org.springframework.integration.support.management.MessageHandlerMetrics delegate) { + this.lifecycle = lifecycle; this.delegate = delegate; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageSourceManagement.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageSourceManagement.java index 9bbd0b3e94..cc25fa58ff 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageSourceManagement.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageSourceManagement.java @@ -25,6 +25,7 @@ import org.springframework.context.Lifecycle; * @since 5.0 * */ +@SuppressWarnings("deprecation") public class LifecycleMessageSourceManagement extends LifecycleMessageSourceMetrics implements MessageSourceManagement { public LifecycleMessageSourceManagement(Lifecycle lifecycle, MessageSourceManagement delegate) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageSourceMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageSourceMetrics.java index 018d32f8f2..80b1b72a8c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageSourceMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleMessageSourceMetrics.java @@ -23,13 +23,16 @@ import org.springframework.jmx.export.annotation.ManagedOperation; /** * A {@link MessageSourceMetrics} that exposes in addition the {@link Lifecycle} interface. * The lifecycle methods can be used to start and stop polling endpoints, for instance, in a live system. - * + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @author Dave Syer * @author Gary Russell * @author Artem Bilan * * @since 2.0 */ +@Deprecated @IntegrationManagedResource public class LifecycleMessageSourceMetrics implements MessageSourceMetrics, Lifecycle { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageHandlerMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageHandlerMetrics.java index 768175ef0a..412786564c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageHandlerMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageHandlerMetrics.java @@ -21,12 +21,16 @@ import org.springframework.util.Assert; /** * Adds {@link TrackableComponent}. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * * @author Gary Russell * @author Artem Bilan * * @since 4.2 */ +@Deprecated @IntegrationManagedResource public class LifecycleTrackableMessageHandlerMetrics extends LifecycleMessageHandlerMetrics implements TrackableComponent { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageSourceManagement.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageSourceManagement.java index c5089efd47..400f97ea09 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageSourceManagement.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageSourceManagement.java @@ -26,6 +26,7 @@ import org.springframework.context.Lifecycle; * @since 5.0 * */ +@SuppressWarnings("deprecation") public class LifecycleTrackableMessageSourceManagement extends LifecycleTrackableMessageSourceMetrics implements MessageSourceManagement { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageSourceMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageSourceMetrics.java index 196f593f2c..48fa1a8aff 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageSourceMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/LifecycleTrackableMessageSourceMetrics.java @@ -27,6 +27,7 @@ import org.springframework.util.Assert; * * @since 2.0 */ +@SuppressWarnings("deprecation") @IntegrationManagedResource public class LifecycleTrackableMessageSourceMetrics extends LifecycleMessageSourceMetrics implements TrackableComponent { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageChannelMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageChannelMetrics.java index e15287d9e9..e9e4a05720 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageChannelMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageChannelMetrics.java @@ -20,14 +20,18 @@ import org.springframework.jmx.export.annotation.ManagedMetric; import org.springframework.jmx.support.MetricType; /** - * Interface for all message channel monitors containing accessors for various useful metrics that are generic for all - * channel types. + * Interface for all message channel monitors containing accessors for various useful + * metrics that are generic for all channel types. * * @author Dave Syer * @author Gary Russell + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @since 2.0 */ -public interface MessageChannelMetrics extends IntegrationStatsManagement { +@Deprecated +public interface MessageChannelMetrics extends BaseChannelMetrics { /** * @return the number of successful sends @@ -42,6 +46,12 @@ public interface MessageChannelMetrics extends IntegrationStatsManagement { @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Send Count") long getSendCountLong(); + + @Override + default long sendCount() { + return getSendCountLong(); + } + /** * @return the number of failed sends (either throwing an exception or rejected by the channel) */ @@ -55,6 +65,11 @@ public interface MessageChannelMetrics extends IntegrationStatsManagement { @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Send Error Count") long getSendErrorCountLong(); + @Override + default long sendErrorCount() { + return getSendErrorCountLong(); + } + /** * @return the time in milliseconds since the last send */ diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageHandlerMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageHandlerMetrics.java index 0dc04635d7..47fd776d44 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageHandlerMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageHandlerMetrics.java @@ -22,9 +22,13 @@ import org.springframework.jmx.support.MetricType; /** * @author Dave Syer * @author Gary Russell + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @since 2.0 */ -public interface MessageHandlerMetrics extends IntegrationStatsManagement { +@Deprecated +public interface MessageHandlerMetrics extends BaseHandlerMetrics { /** * @return the number of successful handler calls @@ -39,6 +43,12 @@ public interface MessageHandlerMetrics extends IntegrationStatsManagement { @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Execution Count") long getHandleCountLong(); + + @Override + default long handleCount() { + return getHandleCountLong(); + } + /** * @return the number of failed handler calls */ @@ -52,6 +62,11 @@ public interface MessageHandlerMetrics extends IntegrationStatsManagement { @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Error Count") long getErrorCountLong(); + @Override + default long errorCount() { + return getErrorCountLong(); + } + /** * @return the mean handler duration (milliseconds) */ diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceManagement.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceManagement.java index 72b626e33e..b30aff538a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceManagement.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceManagement.java @@ -26,6 +26,7 @@ import org.springframework.jmx.export.annotation.ManagedAttribute; * @since 5.0 * */ +@SuppressWarnings("deprecation") @IntegrationManagedResource public interface MessageSourceManagement extends MessageSourceMetrics { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceMetrics.java index ca4a709d93..986050373d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceMetrics.java @@ -23,13 +23,16 @@ import org.springframework.jmx.support.MetricType; * @author Dave Syer * @author Gary Russell * @author Artem Bilan - * + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @since 2.0 */ -public interface MessageSourceMetrics extends IntegrationManagement { +@Deprecated +public interface MessageSourceMetrics extends BaseSourceMetrics { /** - * @return the number of successful handler calls + * @return the number of successful message receptions. */ @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Message Source Message Count") int getMessageCount(); @@ -41,6 +44,11 @@ public interface MessageSourceMetrics extends IntegrationManagement { @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Message Source Message Count") long getMessageCountLong(); + @Override + default long messageCount() { + return getMessageCountLong(); + } + void setManagedName(String name); String getManagedName(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceMetricsConfigurer.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceMetricsConfigurer.java index b10fedebcd..a775419ddd 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceMetricsConfigurer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MessageSourceMetricsConfigurer.java @@ -18,12 +18,17 @@ package org.springframework.integration.support.management; /** * Perform additional configuration on {@link MessageSourceMetrics}. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * * @author Gary Russell * @since 5.0.2 * */ +@Deprecated @FunctionalInterface +@SuppressWarnings("deprecation") public interface MessageSourceMetricsConfigurer { void configure(MessageSourceMetrics metrics, String beanName); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MetricsContext.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MetricsContext.java index d83b663808..a60b5d8953 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MetricsContext.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MetricsContext.java @@ -19,11 +19,13 @@ package org.springframework.integration.support.management; /** * Interface representing an opaque object containing state between initiating an * event and concluding it. - * + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @author Gary Russell * @since 4.2 - * */ +@Deprecated public interface MetricsContext { } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MetricsFactory.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MetricsFactory.java index a363274f7d..3ca954a29e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/MetricsFactory.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/MetricsFactory.java @@ -19,11 +19,14 @@ package org.springframework.integration.support.management; /** * Factories implementing this interface provide metric objects for message channels and * message handlers. - * + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. * @author Gary Russell * @since 4.2 * */ +@Deprecated public interface MetricsFactory { /** diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/PollableChannelManagement.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/PollableChannelManagement.java index 6608247927..4099a37dab 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/PollableChannelManagement.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/PollableChannelManagement.java @@ -26,7 +26,7 @@ import org.springframework.jmx.support.MetricType; * @since 4.2 * */ -public interface PollableChannelManagement extends MessageChannelMetrics { +public interface PollableChannelManagement extends PollableChannelMetrics { @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Count") int getReceiveCount(); @@ -34,10 +34,20 @@ public interface PollableChannelManagement extends MessageChannelMetrics { @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Count") long getReceiveCountLong(); + @Override + default long receiveCount() { + return getReceiveCountLong(); + } + @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Error Count") int getReceiveErrorCount(); @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Error Count") long getReceiveErrorCountLong(); + @Override + default long receiveErrorCount() { + return getReceiveErrorCountLong(); + } + } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/PollableChannelMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/PollableChannelMetrics.java new file mode 100644 index 0000000000..f1632ce4d8 --- /dev/null +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/PollableChannelMetrics.java @@ -0,0 +1,35 @@ +/* + * Copyright 2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.support.management; + +import org.springframework.jmx.export.annotation.ManagedMetric; +import org.springframework.jmx.support.MetricType; + +/** + * @author Gary Russell + * @since 5.2 + * + */ +public interface PollableChannelMetrics extends IntegrationStatsManagement { + + @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Receive Count") + long receiveCount(); + + @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Receive Error Count") + long receiveErrorCount(); + +} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/RouterMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/RouterMetrics.java index 104fb883b1..1e5351f27e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/RouterMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/RouterMetrics.java @@ -29,6 +29,7 @@ import org.springframework.context.Lifecycle; * @since 4.2 * */ +@SuppressWarnings("deprecation") public class RouterMetrics extends LifecycleMessageHandlerMetrics implements MappingMessageRouterManagement { private final MappingMessageRouterManagement router; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/Statistics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/Statistics.java index 21fe2567fd..f26986d678 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/Statistics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/Statistics.java @@ -17,10 +17,16 @@ package org.springframework.integration.support.management; /** + * Statistics. + * @deprecated in favor of dimensional metrics via + * {@link org.springframework.integration.support.management.metrics.MeterFacade}. + * Built-in metrics will be removed in a future release. + * * @author Dave Syer * @author Gary Russell * @since 2.0 */ +@Deprecated public class Statistics { private final long count; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorTests.java index a045513e80..596c8930d0 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorTests.java @@ -148,7 +148,7 @@ public class GlobalChannelInterceptorTests { ConfigurableListableBeanFactory beanFactory = this.applicationContext.getBeanFactory(); beanFactory.initializeBean(testChannel, "testChannel"); - List channelInterceptors = testChannel.getChannelInterceptors(); + List channelInterceptors = testChannel.getInterceptors(); assertThat(channelInterceptors.size()).isEqualTo(2); assertThat(channelInterceptors.get(0)).isInstanceOf(SampleInterceptor.class); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalWireTapTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalWireTapTests.java index 7662d5e3ef..c4f6ae104f 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalWireTapTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalWireTapTests.java @@ -87,7 +87,7 @@ public class GlobalWireTapTests { assertThat(this.wiretapAll2.receive(1)).isNull(); - assertThat(this.channel.getChannelInterceptors().size()).isEqualTo(4); + assertThat(this.channel.getInterceptors().size()).isEqualTo(4); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ImplicitConsumerChannelTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ImplicitConsumerChannelTests.java index 75239be773..2976e7641e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ImplicitConsumerChannelTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ImplicitConsumerChannelTests.java @@ -53,15 +53,15 @@ public class ImplicitConsumerChannelTests { @Test public void testImplicit() { // used to fail to load AC (no channel 'bar') - List barInterceptors = bar.getChannelInterceptors(); + List barInterceptors = bar.getInterceptors(); assertThat(barInterceptors.size()).isEqualTo(2); assertThat(barInterceptors.get(0)).isInstanceOfAny(Interceptor1.class, Interceptor2.class); assertThat(barInterceptors.get(1)).isInstanceOfAny(Interceptor1.class, Interceptor2.class); - List fooInterceptors = foo.getChannelInterceptors(); + List fooInterceptors = foo.getInterceptors(); assertThat(fooInterceptors.size()).isEqualTo(2); assertThat(fooInterceptors.get(0)).isInstanceOfAny(WireTap.class, Interceptor2.class); assertThat(fooInterceptors.get(1)).isInstanceOfAny(WireTap.class, Interceptor2.class); - List bazInterceptors = baz.getChannelInterceptors(); + List bazInterceptors = baz.getInterceptors(); assertThat(bazInterceptors.size()).isEqualTo(2); assertThat(bazInterceptors.get(0)).isInstanceOfAny(WireTap.class, Interceptor1.class); assertThat(bazInterceptors.get(1)).isInstanceOfAny(WireTap.class, Interceptor1.class); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java index 18a09b87b5..dc191e560d 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java @@ -472,8 +472,8 @@ public class EnableIntegrationTests { child.refresh(); AbstractMessageChannel foo = child.getBean("foo", AbstractMessageChannel.class); ChannelInterceptor baz = child.getBean("baz", ChannelInterceptor.class); - assertThat(foo.getChannelInterceptors().contains(baz)).isTrue(); - assertThat(this.output.getChannelInterceptors().contains(baz)).isFalse(); + assertThat(foo.getInterceptors().contains(baz)).isTrue(); + assertThat(this.output.getInterceptors().contains(baz)).isFalse(); child.close(); } @@ -485,8 +485,8 @@ public class EnableIntegrationTests { child.refresh(); AbstractMessageChannel foo = child.getBean("foo", AbstractMessageChannel.class); ChannelInterceptor baz = child.getBean("baz", ChannelInterceptor.class); - assertThat(foo.getChannelInterceptors().contains(baz)).isTrue(); - assertThat(this.output.getChannelInterceptors().contains(baz)).isFalse(); + assertThat(foo.getInterceptors().contains(baz)).isTrue(); + assertThat(this.output.getInterceptors().contains(baz)).isFalse(); child.close(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java index 3f19ec3bea..4b38100ae6 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java @@ -39,7 +39,6 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationNotAllowedException; import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; @@ -574,8 +573,7 @@ public class ManualFlowTests { } - private final class BeanFactoryHandler extends AbstractReplyProducingMessageHandler - implements DisposableBean { + private final class BeanFactoryHandler extends AbstractReplyProducingMessageHandler { @Autowired private BeanFactory beanFactory; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRateTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRateTests.java index 5c0fbb070e..2ef07599b3 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRateTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRateTests.java @@ -36,6 +36,7 @@ import org.springframework.util.StopWatch; * @author Artem Bilan */ @Ignore("Very sensitive to the time. Don't forget to test after some changes.") +@SuppressWarnings("deprecation") public class ExponentialMovingAverageRateTests { private static final Log logger = LogFactory.getLog(ExponentialMovingAverageRateTests.class); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRatioTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRatioTests.java index 5b674c9090..c078e6e47c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRatioTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRatioTests.java @@ -33,6 +33,7 @@ import org.springframework.integration.test.util.TestUtils; * @author Steven Swor */ @Ignore("Very sensitive to the time. Don't forget to test after some changes.") +@SuppressWarnings("deprecation") public class ExponentialMovingAverageRatioTests { private final ExponentialMovingAverageRatio history = new ExponentialMovingAverageRatio(0.5, 10, true); @@ -69,7 +70,7 @@ public class ExponentialMovingAverageRatioTests { * time. */ double timeSinceLastMeasurement = history.getTimeSinceLastMeasurement(); - assertThat(timeSinceLastMeasurement).isGreaterThan((double) (sleepTime / 100)); + assertThat(timeSinceLastMeasurement).isGreaterThan(sleepTime / 100); assertThat(timeSinceLastMeasurement).isLessThanOrEqualTo(1.5 * sleepTime / 100); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageTests.java index 89cbbbc6ea..829cb9fd6b 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageTests.java @@ -28,6 +28,7 @@ import org.junit.Test; * @author Gary Russell */ @Ignore("Very sensitive to the time. Don't forget to test after some changes.") +@SuppressWarnings("deprecation") public class ExponentialMovingAverageTests { private final ExponentialMovingAverage history = new ExponentialMovingAverage(10); diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/config/IntegrationMBeanExportConfiguration.java b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/config/IntegrationMBeanExportConfiguration.java index 942cbcb181..0261247a20 100644 --- a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/config/IntegrationMBeanExportConfiguration.java +++ b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/config/IntegrationMBeanExportConfiguration.java @@ -99,6 +99,7 @@ public class IntegrationMBeanExportConfiguration implements ImportAware, Environ "@EnableIntegrationMBeanExport is not present on importing class " + importMetadata.getClassName()); } + @SuppressWarnings("deprecation") @Bean(name = MBEAN_EXPORTER_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public IntegrationMBeanExporter mbeanExporter() { diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMBeanExporter.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMBeanExporter.java index eb812fc826..ccdbd82cce 100644 --- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMBeanExporter.java +++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMBeanExporter.java @@ -55,20 +55,13 @@ import org.springframework.integration.gateway.MessagingGatewaySupport; import org.springframework.integration.handler.AbstractMessageProducingHandler; import org.springframework.integration.history.MessageHistoryConfigurer; import org.springframework.integration.support.context.NamedComponent; -import org.springframework.integration.support.management.LifecycleMessageHandlerMetrics; import org.springframework.integration.support.management.LifecycleMessageSourceManagement; -import org.springframework.integration.support.management.LifecycleMessageSourceMetrics; -import org.springframework.integration.support.management.LifecycleTrackableMessageHandlerMetrics; import org.springframework.integration.support.management.LifecycleTrackableMessageSourceManagement; import org.springframework.integration.support.management.LifecycleTrackableMessageSourceMetrics; import org.springframework.integration.support.management.MappingMessageRouterManagement; -import org.springframework.integration.support.management.MessageChannelMetrics; -import org.springframework.integration.support.management.MessageHandlerMetrics; import org.springframework.integration.support.management.MessageSourceManagement; -import org.springframework.integration.support.management.MessageSourceMetrics; import org.springframework.integration.support.management.PollableChannelManagement; import org.springframework.integration.support.management.RouterMetrics; -import org.springframework.integration.support.management.Statistics; import org.springframework.integration.support.management.TrackableComponent; import org.springframework.integration.support.management.TrackableRouterMetrics; import org.springframework.integration.support.utils.PatternMatchUtils; @@ -114,6 +107,7 @@ import org.springframework.util.ReflectionUtils; * @author Meherzad Lahewala */ @ManagedResource +@SuppressWarnings("deprecation") public class IntegrationMBeanExporter extends MBeanExporter implements ApplicationContextAware, DestructionAwareBeanPostProcessor { @@ -129,17 +123,22 @@ public class IntegrationMBeanExporter extends MBeanExporter private final Map anonymousSourceCounters = new HashMap<>(); - private final Set handlers = new HashSet<>(); + private final Set + handlers = new HashSet<>(); - private final Set sources = new HashSet<>(); + private final Set + sources = new HashSet<>(); private final Set inboundLifecycleMessageProducers = new HashSet<>(); - private final Set channels = new HashSet<>(); + private final Set + channels = new HashSet<>(); - private final Map allChannelsByName = new HashMap<>(); + private final Map + allChannelsByName = new HashMap<>(); - private final Map allSourcesByName = new HashMap<>(); + private final Map + allSourcesByName = new HashMap<>(); private final Map endpointsByMonitor = new HashMap<>(); @@ -256,11 +255,14 @@ public class IntegrationMBeanExporter extends MBeanExporter } private void populateMessageHandlers() { - Map messageHandlers = - this.applicationContext.getBeansOfType(MessageHandlerMetrics.class); - for (Entry entry : messageHandlers.entrySet()) { + Map messageHandlers = + this.applicationContext + .getBeansOfType(org.springframework.integration.support.management.MessageHandlerMetrics.class); + for (Entry entry + : messageHandlers.entrySet()) { + String beanName = entry.getKey(); - MessageHandlerMetrics bean = entry.getValue(); + org.springframework.integration.support.management.MessageHandlerMetrics bean = entry.getValue(); if (this.handlerInAnonymousWrapper(bean) != null) { if (logger.isDebugEnabled()) { logger.debug("Skipping " + beanName + " because it wraps another handler"); @@ -269,30 +271,33 @@ public class IntegrationMBeanExporter extends MBeanExporter } // 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); + org.springframework.integration.support.management.MessageHandlerMetrics monitor = + (org.springframework.integration.support.management.MessageHandlerMetrics) extractTarget(bean); this.handlers.add(monitor); } } private void populateMessageSources() { - this.applicationContext.getBeansOfType(MessageSourceMetrics.class) + this.applicationContext.getBeansOfType( + org.springframework.integration.support.management.MessageSourceMetrics.class) .values() .stream() // If the channel is proxied, we have to extract the target to expose as an MBean. // The MetadataMBeanInfoAssembler does not support JDK dynamic proxies. .map(this::extractTarget) - .map(MessageSourceMetrics.class::cast) + .map(org.springframework.integration.support.management.MessageSourceMetrics.class::cast) .forEach(this.sources::add); } private void populateMessageChannels() { - this.applicationContext.getBeansOfType(MessageChannelMetrics.class) + this.applicationContext.getBeansOfType( + org.springframework.integration.support.management.MessageChannelMetrics.class) .values() .stream() // If the channel is proxied, we have to extract the target to expose as an MBean. // The MetadataMBeanInfoAssembler does not support JDK dynamic proxies. .map(this::extractTarget) - .map(MessageChannelMetrics.class::cast) + .map(org.springframework.integration.support.management.MessageChannelMetrics.class::cast) .forEach(this.channels::add); } @@ -324,8 +329,9 @@ public class IntegrationMBeanExporter extends MBeanExporter public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (this.singletonsInstantiated) { try { - if (bean instanceof MessageChannelMetrics) { - MessageChannelMetrics monitor = (MessageChannelMetrics) extractTarget(bean); + if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) { + org.springframework.integration.support.management.MessageChannelMetrics monitor = + (org.springframework.integration.support.management.MessageChannelMetrics) extractTarget(bean); this.channels.add(monitor); registerChannel(monitor); this.runtimeBeans.add(bean); @@ -349,9 +355,9 @@ public class IntegrationMBeanExporter extends MBeanExporter if (bean instanceof IntegrationConsumer) { IntegrationConsumer integrationConsumer = (IntegrationConsumer) bean; MessageHandler handler = integrationConsumer.getHandler(); - if (handler instanceof MessageHandlerMetrics) { - MessageHandlerMetrics messageHandlerMetrics = - (MessageHandlerMetrics) extractTarget(handler); + if (handler instanceof org.springframework.integration.support.management.MessageHandlerMetrics) { + org.springframework.integration.support.management.MessageHandlerMetrics messageHandlerMetrics = + (org.springframework.integration.support.management.MessageHandlerMetrics) extractTarget(handler); registerHandler(messageHandlerMetrics); this.handlers.add(messageHandlerMetrics); this.runtimeBeans.add(messageHandlerMetrics); @@ -361,9 +367,10 @@ public class IntegrationMBeanExporter extends MBeanExporter else if (bean instanceof SourcePollingChannelAdapter) { SourcePollingChannelAdapter pollingChannelAdapter = (SourcePollingChannelAdapter) bean; MessageSource messageSource = pollingChannelAdapter.getMessageSource(); - if (messageSource instanceof MessageSourceMetrics) { - MessageSourceMetrics messageSourceMetrics = - (MessageSourceMetrics) extractTarget(messageSource); + if (messageSource instanceof org.springframework.integration.support.management.MessageSourceMetrics) { + org.springframework.integration.support.management.MessageSourceMetrics messageSourceMetrics = + (org.springframework.integration.support.management.MessageSourceMetrics) + extractTarget(messageSource); registerSource(messageSourceMetrics); this.sources.add(messageSourceMetrics); this.runtimeBeans.add(messageSourceMetrics); @@ -384,9 +391,9 @@ public class IntegrationMBeanExporter extends MBeanExporter @Override public boolean requiresDestruction(Object bean) { - return bean instanceof MessageChannelMetrics || // NOSONAR - bean instanceof MessageHandlerMetrics || - bean instanceof MessageSourceMetrics || + return bean instanceof org.springframework.integration.support.management.MessageChannelMetrics || // NOSONAR + bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics || + bean instanceof org.springframework.integration.support.management.MessageSourceMetrics || (bean instanceof MessageProducer && bean instanceof Lifecycle) || bean instanceof AbstractEndpoint; } @@ -403,18 +410,20 @@ public class IntegrationMBeanExporter extends MBeanExporter else { this.endpointsByMonitor.remove(bean); - if (bean instanceof MessageChannelMetrics) { + if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) { this.channels.remove(bean); this.allChannelsByName.remove(((NamedComponent) bean).getComponentName()); } - else if (bean instanceof MessageHandlerMetrics) { + else if (bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics) { this.handlers.remove(bean); this.endpointNames.remove(((NamedComponent) bean).getComponentName()); } - else if (bean instanceof MessageSourceMetrics) { + else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics) { this.sources.remove(bean); this.endpointNames.remove(((NamedComponent) bean).getComponentName()); - String managedName = ((MessageSourceMetrics) bean).getManagedName(); + String managedName = + ((org.springframework.integration.support.management.MessageSourceMetrics) bean) + .getManagedName(); this.allSourcesByName.remove(managedName); } } @@ -489,13 +498,13 @@ public class IntegrationMBeanExporter extends MBeanExporter @Override public void destroy() { super.destroy(); - for (MessageChannelMetrics monitor : this.channels) { + for (org.springframework.integration.support.management.MessageChannelMetrics monitor : this.channels) { logger.info("Summary on shutdown: " + monitor); } - for (MessageHandlerMetrics monitor : this.handlers) { + for (org.springframework.integration.support.management.MessageHandlerMetrics monitor : this.handlers) { logger.info("Summary on shutdown: " + monitor); } - for (MessageSourceMetrics monitor : this.sources) { + for (org.springframework.integration.support.management.MessageSourceMetrics monitor : this.sources) { logger.info("Summary on shutdown: " + monitor); } } @@ -554,7 +563,9 @@ public class IntegrationMBeanExporter extends MBeanExporter */ @ManagedOperation public void stopMessageSources() { - for (MessageSourceMetrics sourceMetrics : this.allSourcesByName.values()) { + for (org.springframework.integration.support.management.MessageSourceMetrics sourceMetrics + : this.allSourcesByName.values()) { + if (sourceMetrics instanceof Lifecycle) { if (logger.isInfoEnabled()) { logger.info("Stopping message source " + sourceMetrics); @@ -588,7 +599,7 @@ public class IntegrationMBeanExporter extends MBeanExporter @ManagedOperation public void stopActiveChannels() { // Stop any "active" channels (JMS etc). - for (MessageChannelMetrics metrics : this.allChannelsByName.values()) { + for (org.springframework.integration.support.management.MessageChannelMetrics metrics : this.allChannelsByName.values()) { MessageChannel channel = (MessageChannel) metrics; if (channel instanceof Lifecycle) { if (logger.isInfoEnabled()) { @@ -653,7 +664,7 @@ public class IntegrationMBeanExporter extends MBeanExporter @ManagedMetric(metricType = MetricType.GAUGE, displayName = "Active Handler Count") public long getActiveHandlerCountLong() { int count = 0; - for (MessageHandlerMetrics monitor : this.handlers) { + for (org.springframework.integration.support.management.MessageHandlerMetrics monitor : this.handlers) { count += monitor.getActiveCountLong(); } return count; @@ -673,12 +684,12 @@ public class IntegrationMBeanExporter extends MBeanExporter return this.managementConfigurer.getChannelNames(); } - public MessageHandlerMetrics getHandlerMetrics(String name) { + public org.springframework.integration.support.management.MessageHandlerMetrics getHandlerMetrics(String name) { return this.managementConfigurer.getHandlerMetrics(name); } - public Statistics getHandlerDuration(String name) { - MessageHandlerMetrics handlerMetrics = getHandlerMetrics(name); + public org.springframework.integration.support.management.Statistics getHandlerDuration(String name) { + org.springframework.integration.support.management.MessageHandlerMetrics handlerMetrics = getHandlerMetrics(name); return handlerMetrics != null ? handlerMetrics.getDuration() : null; } @@ -687,7 +698,7 @@ public class IntegrationMBeanExporter extends MBeanExporter return this.managementConfigurer.getSourceNames(); } - public MessageSourceMetrics getSourceMetrics(String name) { + public org.springframework.integration.support.management.MessageSourceMetrics getSourceMetrics(String name) { return this.managementConfigurer.getSourceMetrics(name); } @@ -696,11 +707,11 @@ public class IntegrationMBeanExporter extends MBeanExporter } public long getSourceMessageCountLong(String name) { - MessageSourceMetrics sourceMetrics = getSourceMetrics(name); + org.springframework.integration.support.management.MessageSourceMetrics sourceMetrics = getSourceMetrics(name); return sourceMetrics != null ? sourceMetrics.getMessageCountLong() : -1; } - public MessageChannelMetrics getChannelMetrics(String name) { + public org.springframework.integration.support.management.MessageChannelMetrics getChannelMetrics(String name) { return this.managementConfigurer.getChannelMetrics(name); } @@ -709,7 +720,8 @@ public class IntegrationMBeanExporter extends MBeanExporter } public long getChannelSendCountLong(String name) { - MessageChannelMetrics channelMetrics = getChannelMetrics(name); + org.springframework.integration.support.management.MessageChannelMetrics channelMetrics = + getChannelMetrics(name); return channelMetrics != null ? channelMetrics.getSendCountLong() : -1; } @@ -718,7 +730,7 @@ public class IntegrationMBeanExporter extends MBeanExporter } public long getChannelSendErrorCountLong(String name) { - MessageChannelMetrics channelMetrics = getChannelMetrics(name); + org.springframework.integration.support.management.MessageChannelMetrics channelMetrics = getChannelMetrics(name); return channelMetrics != null ? channelMetrics.getSendErrorCountLong() : -1; } @@ -727,7 +739,8 @@ public class IntegrationMBeanExporter extends MBeanExporter } public long getChannelReceiveCountLong(String name) { - MessageChannelMetrics channelMetrics = getChannelMetrics(name); + org.springframework.integration.support.management.MessageChannelMetrics channelMetrics = + getChannelMetrics(name); if (channelMetrics instanceof PollableChannelManagement) { return ((PollableChannelManagement) channelMetrics).getReceiveCountLong(); } @@ -735,13 +748,15 @@ public class IntegrationMBeanExporter extends MBeanExporter } @ManagedOperation - public Statistics getChannelSendRate(String name) { - MessageChannelMetrics channelMetrics = getChannelMetrics(name); + public org.springframework.integration.support.management.Statistics getChannelSendRate(String name) { + org.springframework.integration.support.management.MessageChannelMetrics channelMetrics = + getChannelMetrics(name); return channelMetrics != null ? channelMetrics.getSendRate() : null; } - public Statistics getChannelErrorRate(String name) { - MessageChannelMetrics channelMetrics = getChannelMetrics(name); + public org.springframework.integration.support.management.Statistics getChannelErrorRate(String name) { + org.springframework.integration.support.management.MessageChannelMetrics channelMetrics = + getChannelMetrics(name); return channelMetrics != null ? channelMetrics.getErrorRate() : null; } @@ -749,7 +764,7 @@ public class IntegrationMBeanExporter extends MBeanExporter this.channels.forEach(this::registerChannel); } - private void registerChannel(MessageChannelMetrics monitor) { + private void registerChannel(org.springframework.integration.support.management.MessageChannelMetrics monitor) { String name = ((NamedComponent) monitor).getComponentName(); this.allChannelsByName.put(name, monitor); if (matches(this.componentNamePatterns, name)) { @@ -767,8 +782,8 @@ public class IntegrationMBeanExporter extends MBeanExporter } - private void registerHandler(MessageHandlerMetrics handler) { - MessageHandlerMetrics monitor = enhanceHandlerMonitor(handler); + private void registerHandler(org.springframework.integration.support.management.MessageHandlerMetrics handler) { + org.springframework.integration.support.management.MessageHandlerMetrics monitor = enhanceHandlerMonitor(handler); String name = monitor.getManagedName(); if (!this.objectNames.containsKey(handler) && matches(this.componentNamePatterns, name)) { String beanKey = getHandlerBeanKey(monitor); @@ -784,8 +799,8 @@ public class IntegrationMBeanExporter extends MBeanExporter this.sources.forEach(this::registerSource); } - private void registerSource(MessageSourceMetrics source) { - MessageSourceMetrics monitor = enhanceSourceMonitor(source); + private void registerSource(org.springframework.integration.support.management.MessageSourceMetrics source) { + org.springframework.integration.support.management.MessageSourceMetrics monitor = enhanceSourceMonitor(source); String name = monitor.getManagedName(); this.allSourcesByName.put(name, monitor); if (!this.objectNames.containsKey(source) && matches(this.componentNamePatterns, name)) { @@ -873,13 +888,13 @@ public class IntegrationMBeanExporter extends MBeanExporter quoteIfNecessary(channel), extra); } - private String getHandlerBeanKey(MessageHandlerMetrics handler) { + private String getHandlerBeanKey(org.springframework.integration.support.management.MessageHandlerMetrics handler) { // This ordering of keys seems to work with default settings of JConsole return String.format(this.domain + ":type=MessageHandler,name=%s,bean=%s" + getStaticNames(), quoteIfNecessary(handler.getManagedName()), quoteIfNecessary(handler.getManagedType())); } - private String getSourceBeanKey(MessageSourceMetrics source) { + private String getSourceBeanKey(org.springframework.integration.support.management.MessageSourceMetrics source) { // This ordering of keys seems to work with default settings of JConsole return String.format(this.domain + ":type=MessageSource,name=%s,bean=%s" + getStaticNames(), quoteIfNecessary(source.getManagedName()), quoteIfNecessary(source.getManagedType())); @@ -915,7 +930,10 @@ public class IntegrationMBeanExporter extends MBeanExporter .collect(Collectors.joining(",")); } - private MessageHandlerMetrics enhanceHandlerMonitor(MessageHandlerMetrics monitor) { + @SuppressWarnings("unlikely-arg-type") + private org.springframework.integration.support.management.MessageHandlerMetrics enhanceHandlerMonitor( + org.springframework.integration.support.management.MessageHandlerMetrics monitor) { + if (monitor.getManagedName() != null && monitor.getManagedType() != null) { return monitor; } @@ -945,17 +963,19 @@ public class IntegrationMBeanExporter extends MBeanExporter } } - MessageHandlerMetrics messageHandlerMetrics = buildMessageHandlerMetrics(monitor, name, source, endpoint); + org.springframework.integration.support.management.MessageHandlerMetrics messageHandlerMetrics = + buildMessageHandlerMetrics(monitor, name, source, endpoint); if (endpointName != null) { this.endpointsByMonitor.put(messageHandlerMetrics, endpointName); } return messageHandlerMetrics; } - private MessageHandlerMetrics buildMessageHandlerMetrics(MessageHandlerMetrics monitor, + private org.springframework.integration.support.management.MessageHandlerMetrics buildMessageHandlerMetrics( + org.springframework.integration.support.management.MessageHandlerMetrics monitor, String name, String source, IntegrationConsumer endpoint) { - MessageHandlerMetrics result = monitor; + org.springframework.integration.support.management.MessageHandlerMetrics result = monitor; String managedType = source; String managedName = name; @@ -1003,10 +1023,12 @@ public class IntegrationMBeanExporter extends MBeanExporter /** * Wrap the monitor in a lifecycle so it exposes the start/stop operations */ - private MessageHandlerMetrics wrapMessageHandlerInLifecycleMetrics(MessageHandlerMetrics monitor, - Lifecycle endpoint) { + private org.springframework.integration.support.management.MessageHandlerMetrics + wrapMessageHandlerInLifecycleMetrics( + org.springframework.integration.support.management.MessageHandlerMetrics monitor, + Lifecycle endpoint) { - MessageHandlerMetrics result; + org.springframework.integration.support.management.MessageHandlerMetrics result; if (monitor instanceof MappingMessageRouterManagement) { if (monitor instanceof TrackableComponent) { result = new TrackableRouterMetrics(endpoint, @@ -1018,10 +1040,12 @@ public class IntegrationMBeanExporter extends MBeanExporter } else { if (monitor instanceof TrackableComponent) { - result = new LifecycleTrackableMessageHandlerMetrics(endpoint, monitor); + result = new org.springframework.integration.support.management. + LifecycleTrackableMessageHandlerMetrics(endpoint, monitor); } else { - result = new LifecycleMessageHandlerMetrics(endpoint, monitor); + result = new org.springframework.integration.support.management. + LifecycleMessageHandlerMetrics(endpoint, monitor); } } return result; @@ -1031,7 +1055,9 @@ public class IntegrationMBeanExporter extends MBeanExporter return name.substring(('_' + SI_PACKAGE).length() + 1); } - private MessageSourceMetrics enhanceSourceMonitor(MessageSourceMetrics monitor) { + private org.springframework.integration.support.management.MessageSourceMetrics enhanceSourceMonitor( + org.springframework.integration.support.management.MessageSourceMetrics monitor) { + if (monitor.getManagedName() != null) { return monitor; } @@ -1048,7 +1074,7 @@ public class IntegrationMBeanExporter extends MBeanExporter source = "internal"; } - MessageSourceMetrics messageSourceMetrics = + org.springframework.integration.support.management.MessageSourceMetrics messageSourceMetrics = buildMessageSourceMetricsIfAny(monitor, endpointName, source, endpoint); if (endpointName != null) { this.endpointsByMonitor.put(messageSourceMetrics, endpointName); @@ -1056,7 +1082,10 @@ public class IntegrationMBeanExporter extends MBeanExporter return messageSourceMetrics; } - private AbstractEndpoint getEndpointForMonitor(MessageSourceMetrics monitor) { + @SuppressWarnings("unlikely-arg-type") + private AbstractEndpoint getEndpointForMonitor( + org.springframework.integration.support.management.MessageSourceMetrics monitor) { + for (AbstractEndpoint endpoint : this.applicationContext.getBeansOfType(AbstractEndpoint.class).values()) { Object target = null; if (monitor instanceof MessagingGatewaySupport && endpoint.equals(monitor)) { @@ -1072,10 +1101,11 @@ public class IntegrationMBeanExporter extends MBeanExporter return null; } - private MessageSourceMetrics buildMessageSourceMetricsIfAny(MessageSourceMetrics monitor, String name, + private org.springframework.integration.support.management.MessageSourceMetrics buildMessageSourceMetricsIfAny( + org.springframework.integration.support.management.MessageSourceMetrics monitor, String name, String source, Object endpoint) { - MessageSourceMetrics result = monitor; + org.springframework.integration.support.management.MessageSourceMetrics result = monitor; String managedType = source; String managedName = name; @@ -1122,8 +1152,10 @@ public class IntegrationMBeanExporter extends MBeanExporter /** * Wrap the monitor in a lifecycle so it exposes the start/stop operations */ - private MessageSourceMetrics wrapMessageSourceInLifecycleMetrics(MessageSourceMetrics monitor, Object endpoint) { - MessageSourceMetrics result; + private org.springframework.integration.support.management.MessageSourceMetrics wrapMessageSourceInLifecycleMetrics( + org.springframework.integration.support.management.MessageSourceMetrics monitor, Object endpoint) { + + org.springframework.integration.support.management.MessageSourceMetrics result; if (endpoint instanceof TrackableComponent) { if (monitor instanceof MessageSourceManagement) { result = new LifecycleTrackableMessageSourceManagement((Lifecycle) endpoint, @@ -1139,7 +1171,8 @@ public class IntegrationMBeanExporter extends MBeanExporter (MessageSourceManagement) monitor); } else { - result = new LifecycleMessageSourceMetrics((Lifecycle) endpoint, monitor); + result = new org.springframework.integration.support.management.LifecycleMessageSourceMetrics( + (Lifecycle) endpoint, monitor); } } return result; diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMetadataMBeanInfoAssembler.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMetadataMBeanInfoAssembler.java index 60a74f904e..41580730e0 100644 --- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMetadataMBeanInfoAssembler.java +++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMetadataMBeanInfoAssembler.java @@ -18,14 +18,15 @@ package org.springframework.integration.monitor; import javax.management.Descriptor; -import org.springframework.integration.support.management.LifecycleMessageHandlerMetrics; -import org.springframework.integration.support.management.LifecycleMessageSourceMetrics; import org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler; import org.springframework.jmx.export.metadata.JmxAttributeSource; /** - * The {@link MetadataMBeanInfoAssembler} extension to assemble metadata MBean info - * from the {@link LifecycleMessageSourceMetrics} or {@link LifecycleMessageHandlerMetrics} + * The {@link MetadataMBeanInfoAssembler} extension to assemble metadata MBean info from + * the + * {@link org.springframework.integration.support.management.LifecycleMessageSourceMetrics} + * or + * {@link org.springframework.integration.support.management.LifecycleMessageHandlerMetrics} * managed bean's delegate. *

* All other managed beans are left as is. @@ -51,12 +52,15 @@ public class IntegrationMetadataMBeanInfoAssembler extends MetadataMBeanInfoAsse super.populateMBeanDescriptor(desc, extractManagedBean(managedBean), beanKey); } + @SuppressWarnings("deprecation") private Object extractManagedBean(Object managedBean) { - if (managedBean instanceof LifecycleMessageSourceMetrics) { - return ((LifecycleMessageSourceMetrics) managedBean).getDelegate(); + if (managedBean instanceof org.springframework.integration.support.management.LifecycleMessageSourceMetrics) { + return ((org.springframework.integration.support.management.LifecycleMessageSourceMetrics) managedBean) + .getDelegate(); } - else if (managedBean instanceof LifecycleMessageHandlerMetrics) { - return ((LifecycleMessageHandlerMetrics) managedBean).getDelegate(); + else if (managedBean instanceof org.springframework.integration.support.management.LifecycleMessageHandlerMetrics) { + return ((org.springframework.integration.support.management.LifecycleMessageHandlerMetrics) managedBean) + .getDelegate(); } return managedBean; } diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMetadataNamingStrategy.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMetadataNamingStrategy.java index c9f1f7e088..8820d08a56 100644 --- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMetadataNamingStrategy.java +++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMetadataNamingStrategy.java @@ -19,14 +19,15 @@ package org.springframework.integration.monitor; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; -import org.springframework.integration.support.management.LifecycleMessageHandlerMetrics; -import org.springframework.integration.support.management.LifecycleMessageSourceMetrics; import org.springframework.jmx.export.metadata.JmxAttributeSource; import org.springframework.jmx.export.naming.MetadataNamingStrategy; /** * The {@link MetadataNamingStrategy} naming extension to extract an {@link ObjectName} - * from the {@link LifecycleMessageSourceMetrics} or {@link LifecycleMessageHandlerMetrics} + * from the + * {@link org.springframework.integration.support.management.LifecycleMessageSourceMetrics} + * or + * {@link org.springframework.integration.support.management.LifecycleMessageHandlerMetrics} * managed bean's delegate. *

* Otherwise delegate to the {@link MetadataNamingStrategy#getObjectName} as is. @@ -47,12 +48,15 @@ public class IntegrationMetadataNamingStrategy extends MetadataNamingStrategy { return super.getObjectName(extractManagedBean(managedBean), beanKey); } + @SuppressWarnings("deprecation") private Object extractManagedBean(Object managedBean) { - if (managedBean instanceof LifecycleMessageSourceMetrics) { - return ((LifecycleMessageSourceMetrics) managedBean).getDelegate(); + if (managedBean instanceof org.springframework.integration.support.management.LifecycleMessageSourceMetrics) { + return ((org.springframework.integration.support.management.LifecycleMessageSourceMetrics) managedBean) + .getDelegate(); } - else if (managedBean instanceof LifecycleMessageHandlerMetrics) { - return ((LifecycleMessageHandlerMetrics) managedBean).getDelegate(); + else if (managedBean instanceof org.springframework.integration.support.management.LifecycleMessageHandlerMetrics) { + return ((org.springframework.integration.support.management.LifecycleMessageHandlerMetrics) managedBean) + .getDelegate(); } return managedBean; } diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/MBeanExporterParserTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/MBeanExporterParserTests.java index ef1ca14911..3850a31d99 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/MBeanExporterParserTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/MBeanExporterParserTests.java @@ -34,12 +34,6 @@ import org.springframework.integration.support.management.AbstractMessageChannel import org.springframework.integration.support.management.AbstractMessageHandlerMetrics; import org.springframework.integration.support.management.DefaultMessageChannelMetrics; import org.springframework.integration.support.management.DefaultMessageHandlerMetrics; -import org.springframework.integration.support.management.ExponentialMovingAverage; -import org.springframework.integration.support.management.ExponentialMovingAverageRate; -import org.springframework.integration.support.management.ExponentialMovingAverageRatio; -import org.springframework.integration.support.management.MessageChannelMetrics; -import org.springframework.integration.support.management.MessageHandlerMetrics; -import org.springframework.integration.support.management.MetricsFactory; import org.springframework.integration.test.util.TestUtils; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -56,6 +50,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @DirtiesContext +@SuppressWarnings("deprecation") public class MBeanExporterParserTests { @Autowired @@ -72,38 +67,42 @@ public class MBeanExporterParserTests { assertThat(properties.containsKey("bar")).isTrue(); assertThat(exporter.getServer()).isEqualTo(server); assertThat(TestUtils.getPropertyValue(exporter, "namingStrategy")).isSameAs(context.getBean("keyNamer")); - MessageChannelMetrics metrics = context.getBean("foo", MessageChannelMetrics.class); + org.springframework.integration.support.management.MessageChannelMetrics metrics = + context.getBean("foo", org.springframework.integration.support.management.MessageChannelMetrics.class); assertThat(metrics.isCountsEnabled()).isTrue(); assertThat(metrics.isStatsEnabled()).isFalse(); checkCustomized(metrics); - MessageHandlerMetrics handlerMetrics = context.getBean("transformer.handler", MessageHandlerMetrics.class); + org.springframework.integration.support.management.MessageHandlerMetrics handlerMetrics = + context.getBean("transformer.handler", + org.springframework.integration.support.management.MessageHandlerMetrics.class); checkCustomized(handlerMetrics); - metrics = context.getBean("bar", MessageChannelMetrics.class); + metrics = context.getBean("bar", org.springframework.integration.support.management.MessageChannelMetrics.class); assertThat(metrics.isCountsEnabled()).isTrue(); assertThat(metrics.isStatsEnabled()).isFalse(); - metrics = context.getBean("baz", MessageChannelMetrics.class); + metrics = context.getBean("baz", org.springframework.integration.support.management.MessageChannelMetrics.class); assertThat(metrics.isCountsEnabled()).isFalse(); assertThat(metrics.isStatsEnabled()).isFalse(); - metrics = context.getBean("qux", MessageChannelMetrics.class); + metrics = context.getBean("qux", org.springframework.integration.support.management.MessageChannelMetrics.class); assertThat(metrics.isCountsEnabled()).isFalse(); assertThat(metrics.isStatsEnabled()).isFalse(); - metrics = context.getBean("fiz", MessageChannelMetrics.class); + metrics = context.getBean("fiz", org.springframework.integration.support.management.MessageChannelMetrics.class); assertThat(metrics.isCountsEnabled()).isTrue(); assertThat(metrics.isStatsEnabled()).isTrue(); - metrics = context.getBean("buz", MessageChannelMetrics.class); + metrics = context.getBean("buz", org.springframework.integration.support.management.MessageChannelMetrics.class); assertThat(metrics.isCountsEnabled()).isTrue(); assertThat(metrics.isStatsEnabled()).isTrue(); - metrics = context.getBean("!excluded", MessageChannelMetrics.class); + metrics = context.getBean("!excluded", org.springframework.integration.support.management.MessageChannelMetrics.class); assertThat(metrics.isCountsEnabled()).isFalse(); assertThat(metrics.isStatsEnabled()).isFalse(); checkCustomized(metrics); - MetricsFactory factory = context.getBean(MetricsFactory.class); + org.springframework.integration.support.management.MetricsFactory factory = + context.getBean(org.springframework.integration.support.management.MetricsFactory.class); IntegrationManagementConfigurer configurer = context.getBean(IntegrationManagementConfigurer.class); assertThat(TestUtils.getPropertyValue(configurer, "metricsFactory")).isSameAs(factory); exporter.destroy(); } - private void checkCustomized(MessageChannelMetrics metrics) { + private void checkCustomized(org.springframework.integration.support.management.MessageChannelMetrics metrics) { assertThat(metrics.isLoggingEnabled()).isFalse(); assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendDuration.window")).isEqualTo(20); assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendDuration.factor", Double.class)) @@ -125,26 +124,30 @@ public class MBeanExporterParserTests { .isCloseTo(.001 / 140000, Offset.offset(.01)); } - private void checkCustomized(MessageHandlerMetrics metrics) { + private void checkCustomized(org.springframework.integration.support.management.MessageHandlerMetrics metrics) { assertThat(TestUtils.getPropertyValue(metrics, "handlerMetrics.duration.window")).isEqualTo(20); assertThat(TestUtils.getPropertyValue(metrics, "handlerMetrics.duration.factor", Double.class)) .isCloseTo(1000000., Offset.offset(.01)); } - public static class CustomMetrics implements MetricsFactory { + public static class CustomMetrics implements org.springframework.integration.support.management.MetricsFactory { @Override public AbstractMessageChannelMetrics createChannelMetrics(String name) { return new DefaultMessageChannelMetrics(name, - new ExponentialMovingAverage(20, 1000000.), - new ExponentialMovingAverageRate(2000, 120000, 30, true), - new ExponentialMovingAverageRatio(130000, 40, true), - new ExponentialMovingAverageRate(3000, 140000, 50, true)); + new org.springframework.integration.support.management.ExponentialMovingAverage(20, 1000000.), + new org.springframework.integration.support.management.ExponentialMovingAverageRate(2000, 120000, + 30, true), + new org.springframework.integration.support.management.ExponentialMovingAverageRatio(130000, 40, + true), + new org.springframework.integration.support.management.ExponentialMovingAverageRate(3000, 140000, + 50, true)); } @Override public AbstractMessageHandlerMetrics createHandlerMetrics(String name) { - return new DefaultMessageHandlerMetrics(name, new ExponentialMovingAverage(20, 1000000.)); + return new DefaultMessageHandlerMetrics(name, + new org.springframework.integration.support.management.ExponentialMovingAverage(20, 1000000.)); } } diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/EnableMBeanExportTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/EnableMBeanExportTests.java index 02e517fd38..f492e03685 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/EnableMBeanExportTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/EnableMBeanExportTests.java @@ -40,8 +40,6 @@ import org.springframework.integration.config.EnableIntegrationManagement; import org.springframework.integration.config.IntegrationManagementConfigurer; import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport; import org.springframework.integration.monitor.IntegrationMBeanExporter; -import org.springframework.integration.support.management.DefaultMetricsFactory; -import org.springframework.integration.support.management.MetricsFactory; import org.springframework.integration.test.util.TestUtils; import org.springframework.jmx.support.MBeanServerFactoryBean; import org.springframework.mock.env.MockEnvironment; @@ -71,8 +69,9 @@ public class EnableMBeanExportTests { @Autowired private IntegrationManagementConfigurer configurer; + @SuppressWarnings("deprecation") @Autowired - private MetricsFactory myMetricsFactory; + private org.springframework.integration.support.management.MetricsFactory myMetricsFactory; @SuppressWarnings("unchecked") @Test @@ -142,9 +141,10 @@ public class EnableMBeanExportTests { return new QueueChannel(); } + @SuppressWarnings("deprecation") @Bean - public MetricsFactory myMetricsFactory() { - return new DefaultMetricsFactory(); + public org.springframework.integration.support.management.MetricsFactory myMetricsFactory() { + return new org.springframework.integration.support.management.DefaultMetricsFactory(); } } diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/ChannelIntegrationTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/ChannelIntegrationTests.java index 4c3faf289d..8448d58443 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/ChannelIntegrationTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/ChannelIntegrationTests.java @@ -22,7 +22,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.integration.support.management.MessageHandlerMetrics; +import org.springframework.integration.support.management.BaseHandlerMetrics; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageDeliveryException; import org.springframework.messaging.PollableChannel; @@ -54,6 +54,7 @@ public class ChannelIntegrationTests { @Autowired private IntegrationMBeanExporter messageChannelsMonitor; + @SuppressWarnings("deprecation") @Test public void testMessageChannelStatistics() throws Exception { @@ -76,7 +77,7 @@ public class ChannelIntegrationTests { try { requests.send(new GenericMessage("foo")); } - catch (MessageDeliveryException e) { + catch (@SuppressWarnings("unused") MessageDeliveryException e) { } assertThat(messageChannelsMonitor.getChannelSendCount(intermediateChannelName)).isEqualTo(3); @@ -85,10 +86,11 @@ public class ChannelIntegrationTests { assertThat(messageChannelsMonitor.getChannelMetrics(intermediateChannelName)).isSameAs(intermediate); - MessageHandlerMetrics handlerMetrics = messageChannelsMonitor.getHandlerMetrics("bridge"); + BaseHandlerMetrics handlerMetrics = messageChannelsMonitor + .getHandlerMetrics("bridge"); - assertThat(handlerMetrics.getHandleCount()).isEqualTo(3); - assertThat(handlerMetrics.getErrorCount()).isEqualTo(1); + assertThat(handlerMetrics.handleCount()).isEqualTo(3); + assertThat(handlerMetrics.errorCount()).isEqualTo(1); assertThat(this.sourceChannel.receive(10000)).isNotNull(); diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests.java index ef6acdaece..d49877004d 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests.java @@ -35,7 +35,6 @@ import org.springframework.integration.core.MessagingTemplate; import org.springframework.integration.endpoint.AbstractMessageSource; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; import org.springframework.integration.support.management.DefaultMessageChannelMetrics; -import org.springframework.integration.support.management.MetricsContext; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.Message; import org.springframework.test.annotation.DirtiesContext; @@ -75,6 +74,7 @@ public class MonitorTests { private NullChannel nullChannel; + @SuppressWarnings("deprecation") @Test public void testStats() throws InterruptedException { final CountDownLatch afterSendLatch = new CountDownLatch(1); @@ -87,7 +87,9 @@ public class MonitorTests { Object result = invocation.callRealMethod(); afterSendLatch.countDown(); return result; - }).when(channelMetrics).afterSend(Mockito.any(MetricsContext.class), Mockito.eq(Boolean.TRUE)); + }).when(channelMetrics) + .afterSend(Mockito.any(org.springframework.integration.support.management.MetricsContext.class), + Mockito.eq(Boolean.TRUE)); new DirectFieldAccessor(this.next).setPropertyValue("channelMetrics", channelMetrics); diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java index 80a6243297..7084e8bb4d 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java @@ -66,7 +66,7 @@ import org.springframework.util.Assert; */ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMessageGroupStore - implements BasicMessageGroupStore, InitializingBean, ApplicationContextAware { + implements InitializingBean, ApplicationContextAware { public static final String SEQUENCE_NAME = "messagesSequence"; diff --git a/src/reference/asciidoc/metrics.adoc b/src/reference/asciidoc/metrics.adoc index c7e562a56f..d6b42f9c24 100644 --- a/src/reference/asciidoc/metrics.adoc +++ b/src/reference/asciidoc/metrics.adoc @@ -97,7 +97,7 @@ Starting with version 5.0.2, the framework automatically detects whether the app [[micrometer-integration]] ==== Micrometer Integration -Starting with version 5.0.3, the presence of a https://micrometer.io/[Micrometer] `MeterRegistry` in the application context triggers support for Micrometer metrics in addition to the built-in metrics (note that built-in metrics will be removed in a future release). +Starting with version 5.0.3, the presence of a https://micrometer.io/[Micrometer] `MeterRegistry` in the application context triggers support for Micrometer metrics in addition to the built-in metrics (note that the legacy built-in metrics will be removed in a future release). IMPORTANT: Micrometer was first supported in version 5.0.2, but changes were made to the Micrometer `Meters` in version 5.0.3 to make them more suitable for use in dimensional systems. Further changes were made in 5.0.4.