diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/PollableAmqpChannel.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/PollableAmqpChannel.java index d11e0eb9b9..284858098e 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/PollableAmqpChannel.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/PollableAmqpChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -30,7 +30,6 @@ import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.integration.amqp.support.AmqpHeaderMapper; import org.springframework.integration.channel.ExecutorChannelInterceptorAware; -import org.springframework.integration.support.management.PollableChannelManagement; import org.springframework.integration.support.management.metrics.CounterFacade; import org.springframework.integration.support.management.metrics.MetricsCaptor; import org.springframework.lang.Nullable; @@ -51,8 +50,10 @@ import org.springframework.util.Assert; * * @since 2.1 */ +@SuppressWarnings("deprecation") public class PollableAmqpChannel extends AbstractAmqpChannel - implements PollableChannel, PollableChannelManagement, ExecutorChannelInterceptorAware { + implements PollableChannel, org.springframework.integration.support.management.PollableChannelManagement, + ExecutorChannelInterceptorAware { private final String channelName; @@ -114,21 +115,45 @@ public class PollableAmqpChannel extends AbstractAmqpChannel setAdmin(amqpAdmin); } + /** + * Deprecated. + * @return receive count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getReceiveCount() { return getMetrics().getReceiveCount(); } + /** + * Deprecated. + * @return receive count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getReceiveCountLong() { return getMetrics().getReceiveCountLong(); } + /** + * Deprecated. + * @return receive error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getReceiveErrorCount() { return getMetrics().getReceiveErrorCount(); } + /** + * Deprecated. + * @return receive error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getReceiveErrorCountLong() { return getMetrics().getReceiveErrorCountLong(); 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 18955d935e..e55caea849 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 @@ -35,9 +35,6 @@ import org.springframework.integration.IntegrationPatternType; import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.context.IntegrationObjectSupport; import org.springframework.integration.history.MessageHistory; -import org.springframework.integration.support.management.AbstractMessageChannelMetrics; -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.TrackableComponent; import org.springframework.integration.support.management.metrics.MeterFacade; @@ -71,7 +68,8 @@ import org.springframework.util.StringUtils; public abstract class AbstractMessageChannel extends IntegrationObjectSupport implements MessageChannel, TrackableComponent, InterceptableChannel, org.springframework.integration.support.management.MessageChannelMetrics, - ConfigurableMetricsAware, + org.springframework.integration.support.management.ConfigurableMetricsAware< + org.springframework.integration.support.management.AbstractMessageChannelMetrics>, IntegrationPattern { protected final ChannelInterceptorList interceptors; // NOSONAR @@ -96,7 +94,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport private volatile boolean loggingEnabled = true; - private volatile AbstractMessageChannelMetrics channelMetrics = new DefaultMessageChannelMetrics(); + private volatile org.springframework.integration.support.management.AbstractMessageChannelMetrics channelMetrics + = new org.springframework.integration.support.management.DefaultMessageChannelMetrics(); private MetricsCaptor metricsCaptor; @@ -175,12 +174,26 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport this.managementOverrides.loggingConfigured = true; } - protected AbstractMessageChannelMetrics getMetrics() { + /** + * Deprecated. + * @return channel metrics. + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated + protected org.springframework.integration.support.management.AbstractMessageChannelMetrics getMetrics() { return this.channelMetrics; } + /** + * Deprecated. + * @param metrics the metrics + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override - public void configureMetrics(AbstractMessageChannelMetrics metrics) { + public void configureMetrics( + org.springframework.integration.support.management.AbstractMessageChannelMetrics metrics) { + Assert.notNull(metrics, "'metrics' must not be null"); this.channelMetrics = metrics; this.managementOverrides.metricsConfigured = true; @@ -276,81 +289,176 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport return this.interceptors; } + /** + * Deprecated. + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public void reset() { this.channelMetrics.reset(); } + /** + * Deprecated. + * @return send count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getSendCount() { return this.channelMetrics.getSendCount(); } + /** + * Deprecated. + * @return send count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getSendCountLong() { return this.channelMetrics.getSendCountLong(); } + /** + * Deprecated. + * @return send error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getSendErrorCount() { return this.channelMetrics.getSendErrorCount(); } + /** + * Deprecated. + * @return send error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getSendErrorCountLong() { return this.channelMetrics.getSendErrorCountLong(); } + /** + * Deprecated. + * @return time since last + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getTimeSinceLastSend() { return this.channelMetrics.getTimeSinceLastSend(); } + /** + * Deprecated. + * @return mean send rate + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMeanSendRate() { return this.channelMetrics.getMeanSendRate(); } + /** + * Deprecated. + * @return mean error rate + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMeanErrorRate() { return this.channelMetrics.getMeanErrorRate(); } + /** + * Deprecated. + * @return mean error ratio + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMeanErrorRatio() { return this.channelMetrics.getMeanErrorRatio(); } + /** + * Deprecated. + * @return mean send duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMeanSendDuration() { return this.channelMetrics.getMeanSendDuration(); } + /** + * Deprecated. + * @return min send duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMinSendDuration() { return this.channelMetrics.getMinSendDuration(); } + /** + * Deprecated. + * @return max send duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMaxSendDuration() { return this.channelMetrics.getMaxSendDuration(); } + /** + * Deprecated. + * @return standard deviation send duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getStandardDeviationSendDuration() { return this.channelMetrics.getStandardDeviationSendDuration(); } + /** + * Deprecated. + * @return statistics + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public org.springframework.integration.support.management.Statistics getSendDuration() { return this.channelMetrics.getSendDuration(); } + /** + * Deprecated. + * @return statistics + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public org.springframework.integration.support.management.Statistics getSendRate() { return this.channelMetrics.getSendRate(); } + /** + * Deprecated. + * @return statistics + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public org.springframework.integration.support.management.Statistics getErrorRate() { return this.channelMetrics.getErrorRate(); @@ -439,7 +547,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport org.springframework.integration.support.management.MetricsContext metricsContext = null; boolean countsAreEnabled = this.countsEnabled; ChannelInterceptorList interceptorList = this.interceptors; - AbstractMessageChannelMetrics metrics = this.channelMetrics; + org.springframework.integration.support.management.AbstractMessageChannelMetrics metrics = this.channelMetrics; SampleFacade sample = null; try { message = convertPayloadIfNecessary(message); @@ -687,7 +795,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport @Nullable Exception ex, @Nullable Deque interceptorStack) { if (interceptorStack != null) { - for (Iterator iterator = interceptorStack.descendingIterator(); iterator.hasNext(); ) { + for (Iterator iterator = interceptorStack.descendingIterator(); iterator + .hasNext(); ) { ChannelInterceptor interceptor = iterator.next(); try { interceptor.afterReceiveCompletion(message, channel, ex); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractPollableChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractPollableChannel.java index dec6701a8b..100f4c432d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractPollableChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractPollableChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -21,7 +21,6 @@ import java.util.Deque; import java.util.List; import org.springframework.integration.IntegrationPatternType; -import org.springframework.integration.support.management.PollableChannelManagement; import org.springframework.integration.support.management.metrics.CounterFacade; import org.springframework.integration.support.management.metrics.MetricsCaptor; import org.springframework.lang.Nullable; @@ -38,28 +37,54 @@ import org.springframework.messaging.support.ExecutorChannelInterceptor; * @author Gary Russell * @author Artem Bilan */ +@SuppressWarnings("deprecation") public abstract class AbstractPollableChannel extends AbstractMessageChannel - implements PollableChannel, PollableChannelManagement, ExecutorChannelInterceptorAware { + implements PollableChannel, org.springframework.integration.support.management.PollableChannelManagement, + ExecutorChannelInterceptorAware { private int executorInterceptorsSize; private CounterFacade receiveCounter; + /** + * Deprecated. + * @return receive count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getReceiveCount() { return getMetrics().getReceiveCount(); } + /** + * Deprecated. + * @return receive count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getReceiveCountLong() { return getMetrics().getReceiveCountLong(); } + /** + * Deprecated. + * @return error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getReceiveErrorCount() { return getMetrics().getReceiveErrorCount(); } + /** + * Deprecated. + * @return error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getReceiveErrorCountLong() { return getMetrics().getReceiveErrorCountLong(); 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 adc3164e4c..85c5786f72 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -25,9 +25,6 @@ import org.springframework.beans.factory.BeanNameAware; import org.springframework.integration.IntegrationPattern; import org.springframework.integration.IntegrationPatternType; import org.springframework.integration.support.context.NamedComponent; -import org.springframework.integration.support.management.AbstractMessageChannelMetrics; -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.metrics.CounterFacade; import org.springframework.integration.support.management.metrics.MetricsCaptor; @@ -51,14 +48,16 @@ import org.springframework.util.Assert; @SuppressWarnings("deprecation") public class NullChannel implements PollableChannel, org.springframework.integration.support.management.MessageChannelMetrics, - ConfigurableMetricsAware, BeanNameAware, NamedComponent, - IntegrationPattern { + org.springframework.integration.support.management.ConfigurableMetricsAware< + org.springframework.integration.support.management.AbstractMessageChannelMetrics>, + BeanNameAware, NamedComponent, IntegrationPattern { private final Log logger = LogFactory.getLog(getClass()); private final ManagementOverrides managementOverrides = new ManagementOverrides(); - private AbstractMessageChannelMetrics channelMetrics = new DefaultMessageChannelMetrics("nullChannel"); + private org.springframework.integration.support.management.AbstractMessageChannelMetrics channelMetrics + = new org.springframework.integration.support.management.DefaultMessageChannelMetrics("nullChannel"); private boolean countsEnabled; @@ -77,7 +76,8 @@ public class NullChannel implements PollableChannel, @Override public void setBeanName(String beanName) { this.beanName = beanName; - this.channelMetrics = new DefaultMessageChannelMetrics(this.beanName); + this.channelMetrics = + new org.springframework.integration.support.management.DefaultMessageChannelMetrics(this.beanName); } @Override @@ -119,17 +119,30 @@ public class NullChannel implements PollableChannel, } @Override - public void configureMetrics(AbstractMessageChannelMetrics metrics) { + public void configureMetrics( + org.springframework.integration.support.management.AbstractMessageChannelMetrics metrics) { + Assert.notNull(metrics, "'metrics' must not be null"); this.channelMetrics = metrics; this.managementOverrides.metricsConfigured = true; } + /** + * Deprecated. + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public void reset() { this.channelMetrics.reset(); } + /** + * Deprecated. + * @param countsEnabled the countsEnabled + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public void setCountsEnabled(boolean countsEnabled) { this.countsEnabled = countsEnabled; @@ -140,11 +153,23 @@ public class NullChannel implements PollableChannel, } } + /** + * Deprecated. + * @return counts enabled + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public boolean isCountsEnabled() { return this.countsEnabled; } + /** + * Deprecated. + * @param statsEnabled the statsEnabled + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public void setStatsEnabled(boolean statsEnabled) { if (statsEnabled) { @@ -156,81 +181,178 @@ public class NullChannel implements PollableChannel, this.managementOverrides.statsConfigured = true; } + /** + * Deprecated. + * @return stats enabled + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public boolean isStatsEnabled() { return this.statsEnabled; } + /** + * Deprecated. + * @return send count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getSendCount() { return this.channelMetrics.getSendCount(); } + /** + * Deprecated. + * @return send count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getSendCountLong() { return this.channelMetrics.getSendCountLong(); } + /** + * Deprecated. + * @return error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getSendErrorCount() { return this.channelMetrics.getSendErrorCount(); } + /** + * Deprecated. + * @return error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getSendErrorCountLong() { return this.channelMetrics.getSendErrorCountLong(); } + /** + * Deprecated. + * @return time since last send + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getTimeSinceLastSend() { return this.channelMetrics.getTimeSinceLastSend(); } + /** + * Deprecated. + * @return mean send rate + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMeanSendRate() { return this.channelMetrics.getMeanSendRate(); } + /** + * Deprecated. + * @return mean error rate + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMeanErrorRate() { return this.channelMetrics.getMeanErrorRate(); } + /** + * Deprecated. + * @return mean error ratio + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMeanErrorRatio() { return this.channelMetrics.getMeanErrorRatio(); } + /** + * Deprecated. + * @return mean send duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMeanSendDuration() { return this.channelMetrics.getMeanSendDuration(); } + /** + * Deprecated. + * @return min send duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMinSendDuration() { return this.channelMetrics.getMinSendDuration(); } + /** + * Deprecated. + * @return max send duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMaxSendDuration() { return this.channelMetrics.getMaxSendDuration(); } + /** + * Deprecated. + * @return standard deviation send duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getStandardDeviationSendDuration() { return this.channelMetrics.getStandardDeviationSendDuration(); } + + /** + * Deprecated. + * @return statistics + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public org.springframework.integration.support.management.Statistics getSendDuration() { return this.channelMetrics.getSendDuration(); } + /** + * Deprecated. + * @return statistics + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public org.springframework.integration.support.management.Statistics getSendRate() { return this.channelMetrics.getSendRate(); } + /** + * Deprecated. + * @return statistics + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override 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/QueueChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/QueueChannel.java index 2cbc7deca7..5211f7973a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/QueueChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/QueueChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -25,7 +25,6 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import org.springframework.integration.core.MessageSelector; -import org.springframework.integration.support.management.QueueChannelManagement; import org.springframework.lang.Nullable; import org.springframework.messaging.Message; import org.springframework.util.Assert; @@ -42,8 +41,9 @@ import org.springframework.util.Assert; * @author Gary Russell * @author Artem Bilan */ +@SuppressWarnings("deprecation") public class QueueChannel extends AbstractPollableChannel implements QueueChannelOperations, - QueueChannelManagement { + org.springframework.integration.support.management.QueueChannelManagement { private final Queue> queue; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/AggregatorFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/config/AggregatorFactoryBean.java index 315e4c9513..b26789b521 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/AggregatorFactoryBean.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/AggregatorFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -33,7 +33,6 @@ import org.springframework.integration.aggregator.ReleaseStrategy; import org.springframework.integration.store.MessageGroup; import org.springframework.integration.store.MessageGroupStore; import org.springframework.integration.support.locks.LockRegistry; -import org.springframework.integration.support.management.AbstractMessageHandlerMetrics; import org.springframework.integration.util.JavaUtils; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageHandler; @@ -63,7 +62,8 @@ public class AggregatorFactoryBean extends AbstractSimpleMessageHandlerFactoryBe private String outputChannelName; - private AbstractMessageHandlerMetrics metrics; + @SuppressWarnings("deprecation") + private org.springframework.integration.support.management.AbstractMessageHandlerMetrics metrics; private Boolean statsEnabled; @@ -120,7 +120,14 @@ public class AggregatorFactoryBean extends AbstractSimpleMessageHandlerFactoryBe this.outputChannelName = outputChannelName; } - public void setMetrics(AbstractMessageHandlerMetrics metrics) { + /** + * Deprecated. + * @param metrics the metrics. + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated + @SuppressWarnings("deprecation") + public void setMetrics(org.springframework.integration.support.management.AbstractMessageHandlerMetrics metrics) { this.metrics = metrics; } @@ -192,6 +199,7 @@ public class AggregatorFactoryBean extends AbstractSimpleMessageHandlerFactoryBe this.headersFunction = headersFunction; } + @SuppressWarnings("deprecation") @Override protected AggregatingMessageHandler createHandler() { MessageGroupProcessor outputProcessor; 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 10a22b9765..43d43d89de 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -31,12 +31,8 @@ import org.springframework.beans.factory.config.DestructionAwareBeanPostProcesso import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; 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.IntegrationManagement; import org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides; -import org.springframework.integration.support.management.PollableChannelManagement; import org.springframework.integration.support.management.metrics.MetricsCaptor; import org.springframework.integration.support.management.micrometer.MicrometerMetricsCaptor; import org.springframework.integration.support.utils.PatternMatchUtils; @@ -357,8 +353,8 @@ public class IntegrationManagementConfigurer private void configureChannelMetrics(String name, org.springframework.integration.support.management.MessageChannelMetrics bean) { - AbstractMessageChannelMetrics metrics; - if (bean instanceof PollableChannelManagement) { + org.springframework.integration.support.management.AbstractMessageChannelMetrics metrics; + if (bean instanceof org.springframework.integration.support.management.PollableChannelManagement) { metrics = this.metricsFactory.createPollableChannelMetrics(name); } else { @@ -386,8 +382,11 @@ public class IntegrationManagementConfigurer metrics.setFullStatsEnabled(this.defaultStatsEnabled); } } - if (bean instanceof ConfigurableMetricsAware && !overrides.metricsConfigured) { - ((ConfigurableMetricsAware) bean).configureMetrics(metrics); + if (bean instanceof org.springframework.integration.support.management.ConfigurableMetricsAware + && !overrides.metricsConfigured) { + ((org.springframework.integration.support.management.ConfigurableMetricsAware< + org.springframework.integration.support.management.AbstractMessageChannelMetrics>) bean) + .configureMetrics(metrics); } this.channelsByName.put(name, bean); } @@ -395,7 +394,8 @@ public class IntegrationManagementConfigurer @SuppressWarnings("unchecked") private void configureHandlerMetrics(String name, org.springframework.integration.support.management.MessageHandlerMetrics bean) { - AbstractMessageHandlerMetrics metrics = this.metricsFactory.createHandlerMetrics(name); + org.springframework.integration.support.management.AbstractMessageHandlerMetrics metrics + = this.metricsFactory.createHandlerMetrics(name); Assert.state(metrics != null, "'metrics' must not be null"); ManagementOverrides overrides = getOverrides(bean); Boolean enabled = PatternMatchUtils.smartMatch(name, this.enabledCountsPatterns); @@ -418,8 +418,11 @@ public class IntegrationManagementConfigurer metrics.setFullStatsEnabled(this.defaultStatsEnabled); } } - if (bean instanceof ConfigurableMetricsAware && !overrides.metricsConfigured) { - ((ConfigurableMetricsAware) bean).configureMetrics(metrics); + if (bean instanceof org.springframework.integration.support.management.ConfigurableMetricsAware + && !overrides.metricsConfigured) { + ((org.springframework.integration.support.management.ConfigurableMetricsAware< + org.springframework.integration.support.management.AbstractMessageHandlerMetrics>) bean) + .configureMetrics(metrics); } this.handlersByName.put(bean.getManagedName() != null ? bean.getManagedName() : name, bean); 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 81d99a6383..e6badc42e3 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -49,7 +49,7 @@ import org.springframework.util.CollectionUtils; @IntegrationManagedResource public abstract class AbstractMessageSource extends AbstractExpressionEvaluator implements MessageSource, org.springframework.integration.support.management.MessageSourceMetrics, - NamedComponent, BeanNameAware { + NamedComponent, BeanNameAware { private final AtomicLong messageCount = new AtomicLong(); @@ -141,16 +141,33 @@ public abstract class AbstractMessageSource extends AbstractExpressionEvaluat this.managementOverrides.loggingConfigured = true; } + /** + * Deprecated. + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public void reset() { this.messageCount.set(0); } + /** + * Deprecated. + * @return count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getMessageCount() { return (int) this.messageCount.get(); } + /** + * Deprecated. + * @return count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getMessageCountLong() { return this.messageCount.get(); @@ -179,7 +196,7 @@ public abstract class AbstractMessageSource extends AbstractExpressionEvaluat if (result == null) { return null; } - Message message = null; + Message message; Map headers = evaluateHeaders(); if (result instanceof AbstractIntegrationMessageBuilder) { if (!CollectionUtils.isEmpty(headers)) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java b/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java index 284c401564..a013a68f20 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. 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 8f3e6e0052..3320ff90ec 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -19,7 +19,6 @@ package org.springframework.integration.handler; import org.reactivestreams.Subscription; import org.springframework.integration.history.MessageHistory; -import org.springframework.integration.support.management.AbstractMessageHandlerMetrics; import org.springframework.integration.support.management.metrics.MetricsCaptor; import org.springframework.integration.support.management.metrics.SampleFacade; import org.springframework.integration.support.utils.IntegrationUtils; @@ -38,6 +37,7 @@ import reactor.core.CoreSubscriber; public abstract class AbstractMessageHandler extends MessageHandlerSupport implements MessageHandler, CoreSubscriber> { + @Override @SuppressWarnings("deprecation") // NOSONAR public void handleMessage(Message message) { Message messageToUse = message; @@ -55,7 +55,8 @@ public abstract class AbstractMessageHandler extends MessageHandlerSupport if (shouldTrack()) { messageToUse = MessageHistory.write(messageToUse, this, getMessageBuilderFactory()); } - AbstractMessageHandlerMetrics handlerMetrics = getHandlerMetrics(); + org.springframework.integration.support.management.AbstractMessageHandlerMetrics handlerMetrics + = getHandlerMetrics(); if (isCountsEnabled()) { start = handlerMetrics.beforeHandle(); handleMessageInternal(messageToUse); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/MessageHandlerSupport.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/MessageHandlerSupport.java index 741f9918bd..eb0fb04eee 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/MessageHandlerSupport.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/MessageHandlerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 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. @@ -24,9 +24,6 @@ import org.springframework.integration.IntegrationPattern; import org.springframework.integration.IntegrationPatternType; import org.springframework.integration.context.IntegrationObjectSupport; import org.springframework.integration.context.Orderable; -import org.springframework.integration.support.management.AbstractMessageHandlerMetrics; -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.TrackableComponent; import org.springframework.integration.support.management.metrics.MeterFacade; @@ -54,7 +51,8 @@ import org.springframework.util.Assert; @IntegrationManagedResource public abstract class MessageHandlerSupport extends IntegrationObjectSupport implements org.springframework.integration.support.management.MessageHandlerMetrics, - ConfigurableMetricsAware, + org.springframework.integration.support.management.ConfigurableMetricsAware< + org.springframework.integration.support.management.AbstractMessageHandlerMetrics>, TrackableComponent, Orderable, IntegrationPattern { private final ManagementOverrides managementOverrides = new ManagementOverrides(); @@ -63,7 +61,8 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport private boolean shouldTrack = false; - private AbstractMessageHandlerMetrics handlerMetrics = new DefaultMessageHandlerMetrics(); + private org.springframework.integration.support.management.AbstractMessageHandlerMetrics handlerMetrics + = new org.springframework.integration.support.management.DefaultMessageHandlerMetrics(); private boolean countsEnabled; @@ -97,7 +96,13 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport this.metricsCaptor = metricsCaptorToRegister; } - protected AbstractMessageHandlerMetrics getHandlerMetrics() { + /** + * Deprecated. + * @return handler metrics + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated + protected org.springframework.integration.support.management.AbstractMessageHandlerMetrics getHandlerMetrics() { return this.handlerMetrics; } @@ -129,8 +134,15 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport return this.shouldTrack; } + /** + * Deprecated. + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override - public void configureMetrics(AbstractMessageHandlerMetrics metrics) { + public void configureMetrics( + org.springframework.integration.support.management.AbstractMessageHandlerMetrics metrics) { + Assert.notNull(metrics, "'metrics' must not be null"); this.handlerMetrics = metrics; this.managementOverrides.metricsConfigured = true; @@ -172,66 +184,143 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport return timer; } + /** + * Deprecated. + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public void reset() { this.handlerMetrics.reset(); } + /** + * Deprecated. + * @return handle count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getHandleCountLong() { return this.handlerMetrics.getHandleCountLong(); } + /** + * Deprecated. + * @return handle count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getHandleCount() { return this.handlerMetrics.getHandleCount(); } + /** + * Deprecated. + * @return error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getErrorCount() { return this.handlerMetrics.getErrorCount(); } + /** + * Deprecated. + * @return error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getErrorCountLong() { return this.handlerMetrics.getErrorCountLong(); } + /** + * Deprecated. + * @return mean duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMeanDuration() { return this.handlerMetrics.getMeanDuration(); } + /** + * Deprecated. + * @return min duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMinDuration() { return this.handlerMetrics.getMinDuration(); } + /** + * Deprecated. + * @return max duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getMaxDuration() { return this.handlerMetrics.getMaxDuration(); } + /** + * Deprecated. + * @return standard deviation duration + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public double getStandardDeviationDuration() { return this.handlerMetrics.getStandardDeviationDuration(); } + /** + * Deprecated. + * @return active count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getActiveCount() { return this.handlerMetrics.getActiveCount(); } + /** + * Deprecated. + * @return active count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getActiveCountLong() { return this.handlerMetrics.getActiveCountLong(); } + /** + * Deprecated. + * @return statistics + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public org.springframework.integration.support.management.Statistics getDuration() { return this.handlerMetrics.getDuration(); } + /** + * Deprecated. + * @param statsEnabled the statsEnabled + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public void setStatsEnabled(boolean statsEnabled) { if (statsEnabled) { @@ -245,11 +334,23 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport this.managementOverrides.statsConfigured = true; } + /** + * Deprecated. + * @return statsEnabled + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public boolean isStatsEnabled() { return this.statsEnabled; } + /** + * Deprecated. + * @param countsEnabled the countsEnabled + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public void setCountsEnabled(boolean countsEnabled) { this.countsEnabled = countsEnabled; @@ -260,6 +361,12 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport } } + /** + * Deprecated. + * @return countsEnabled + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public boolean isCountsEnabled() { return this.countsEnabled; 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 83abe00aab..690f9d6c19 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -26,7 +26,9 @@ import org.apache.commons.logging.LogFactory; * * @since 4.2 * - */ + * @deprecated in favor of Micrometer metrics. + **/ +@Deprecated public abstract class AbstractMessageChannelMetrics implements ConfigurableMetrics { private static final String DEPRECATION = "deprecation"; 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 e6e2da8252..f1fc6510ec 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -25,7 +25,9 @@ import org.apache.commons.logging.LogFactory; * @author Gary Russell * @since 4.2 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated @SuppressWarnings("deprecation") public abstract class AbstractMessageHandlerMetrics implements ConfigurableMetrics { 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 dd5f5db0c5..45ab69ef96 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 @@ -1,5 +1,5 @@ /* - * Copyright 2009-2019 the original author or authors. + * Copyright 2009-2020 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. @@ -23,7 +23,10 @@ package org.springframework.integration.support.management; * * @author Gary Russell * @since 4.2 + * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated @SuppressWarnings("deprecation") public class AggregatingMessageChannelMetrics extends DefaultMessageChannelMetrics { 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 6086077626..2b5f117a74 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -24,7 +24,10 @@ package org.springframework.integration.support.management; * * @author Gary Russell * @since 4.2 + * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated @SuppressWarnings("deprecation") public class AggregatingMessageHandlerMetrics extends DefaultMessageHandlerMetrics { 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 index bfc4cdda0a..151fdbc1a3 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 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. @@ -25,7 +25,9 @@ import org.springframework.jmx.support.MetricType; * @author Gary Russell * @since 5.2 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated public interface BaseChannelMetrics extends IntegrationStatsManagement { /** 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 index c51005e7a2..9f2ac88480 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 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. @@ -23,7 +23,9 @@ import org.springframework.jmx.support.MetricType; * @author Gary Russell * @since 5.2 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated public interface BaseHandlerMetrics extends IntegrationStatsManagement { /** diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ConfigurableMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ConfigurableMetrics.java index b527da2715..1e17edeb88 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ConfigurableMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ConfigurableMetrics.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -22,7 +22,9 @@ package org.springframework.integration.support.management; * @author Gary Russell * @since 4.2 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated public interface ConfigurableMetrics { } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ConfigurableMetricsAware.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ConfigurableMetricsAware.java index 6e977e77dd..4298fb5cb9 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ConfigurableMetricsAware.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ConfigurableMetricsAware.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -22,7 +22,9 @@ package org.springframework.integration.support.management; * @author Gary Russell * @since 4.2 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated @FunctionalInterface public interface ConfigurableMetricsAware { 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 57bec6f85a..0b21ba0128 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 @@ -1,5 +1,5 @@ /* - * Copyright 2009-2019 the original author or authors. + * Copyright 2009-2020 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. @@ -27,7 +27,10 @@ import java.util.concurrent.atomic.AtomicLong; * @author Ivan Krizsan * * @since 2.0 + * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated @SuppressWarnings("deprecation") public class DefaultMessageChannelMetrics extends AbstractMessageChannelMetrics { 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 cf77f6ed41..d27fd294cb 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -24,7 +24,10 @@ import java.util.concurrent.atomic.AtomicLong; * @author Dave Syer * @author Gary Russell * @since 2.0 + * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated @SuppressWarnings("deprecation") public class DefaultMessageHandlerMetrics extends AbstractMessageHandlerMetrics { 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 f7774df8b7..3f92b80607 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -28,6 +28,7 @@ package org.springframework.integration.support.management; * @author Gary Russell * @since 4.2 * + * @deprecated in favor of Micrometer metrics. */ @Deprecated public class DefaultMetricsFactory implements MetricsFactory { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/IntegrationManagement.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/IntegrationManagement.java index 717dcf3f5e..79b49f8966 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/IntegrationManagement.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/IntegrationManagement.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -42,12 +42,29 @@ public interface IntegrationManagement extends DisposableBean { @ManagedAttribute boolean isLoggingEnabled(); + /** + * Deprecated. + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @ManagedOperation void reset(); + /** + * Deprecated. + * @param countsEnabled the countsEnabled + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @ManagedAttribute(description = "Enable message counting statistics") void setCountsEnabled(boolean countsEnabled); + /** + * Deprecated. + * @return counts enabled + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @ManagedAttribute boolean isCountsEnabled(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/IntegrationStatsManagement.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/IntegrationStatsManagement.java index 0eb4cb553c..66c35942c8 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/IntegrationStatsManagement.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/IntegrationStatsManagement.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -25,7 +25,9 @@ import org.springframework.jmx.export.annotation.ManagedAttribute; * @author Gary Russell * @since 4.2 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated public interface IntegrationStatsManagement extends IntegrationManagement { @ManagedAttribute(description = "Enable all statistics") 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 cc25fa58ff..bf2eec86de 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 @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -24,7 +24,9 @@ import org.springframework.context.Lifecycle; * @author Gary Russell * @since 5.0 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated @SuppressWarnings("deprecation") public class LifecycleMessageSourceManagement extends LifecycleMessageSourceMetrics implements MessageSourceManagement { 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 400f97ea09..07d08b5d88 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 @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -25,7 +25,9 @@ import org.springframework.context.Lifecycle; * @author Gary Russell * @since 5.0 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated @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 48fa1a8aff..de26719517 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -26,7 +26,10 @@ import org.springframework.util.Assert; * @author Artem Bilan * * @since 2.0 + * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated @SuppressWarnings("deprecation") @IntegrationManagedResource public class LifecycleTrackableMessageSourceMetrics extends LifecycleMessageSourceMetrics 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 4099a37dab..e3105210f9 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -25,7 +25,9 @@ import org.springframework.jmx.support.MetricType; * @author Gary Russell * @since 4.2 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated public interface PollableChannelManagement extends PollableChannelMetrics { @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Count") 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 index f1632ce4d8..c532db1d1f 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 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. @@ -23,7 +23,9 @@ import org.springframework.jmx.support.MetricType; * @author Gary Russell * @since 5.2 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated public interface PollableChannelMetrics extends IntegrationStatsManagement { @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Receive Count") diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/QueueChannelManagement.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/QueueChannelManagement.java index 9777efc7ac..f489ebf5e9 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/QueueChannelManagement.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/QueueChannelManagement.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -23,7 +23,9 @@ import org.springframework.jmx.support.MetricType; * @author Gary Russell * @since 4.2 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated public interface QueueChannelManagement extends PollableChannelManagement { @ManagedMetric(metricType = MetricType.GAUGE, displayName = "QueueChannel Queue Size") 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 1e5351f27e..d38242719d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -28,7 +28,9 @@ import org.springframework.context.Lifecycle; * @author Gary Russell * @since 4.2 * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated @SuppressWarnings("deprecation") public class RouterMetrics extends LifecycleMessageHandlerMetrics implements MappingMessageRouterManagement { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/TrackableRouterMetrics.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/TrackableRouterMetrics.java index 7ef3b7c706..971d274f01 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/TrackableRouterMetrics.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/TrackableRouterMetrics.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -26,7 +26,10 @@ import org.springframework.util.Assert; * @author Artem Bilan * * @since 2.0 + * + * @deprecated in favor of Micrometer metrics. */ +@Deprecated public class TrackableRouterMetrics extends RouterMetrics implements TrackableComponent { private final TrackableComponent trackable; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/MessageChannelReactiveUtilsTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/MessageChannelReactiveUtilsTests.java index 7b0b90f04d..9c47637349 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/MessageChannelReactiveUtilsTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/MessageChannelReactiveUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 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. @@ -19,6 +19,7 @@ package org.springframework.integration.channel; import static org.assertj.core.api.Assertions.assertThat; import java.time.Duration; +import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.Test; @@ -73,6 +74,7 @@ class MessageChannelReactiveUtilsTests { channel.setCountsEnabled(true); Disposable.Composite compositeDisposable = Disposables.composite(); + AtomicInteger sendCount = new AtomicInteger(); try { int initialRequest = 10; StepVerifier.create(MessageChannelReactiveUtils.toPublisher(channel), initialRequest) @@ -83,6 +85,7 @@ class MessageChannelReactiveUtilsTests { while (true) { if (channel.getSubscriberCount() > 0) { channel.send(new GenericMessage<>("foo")); + sendCount.incrementAndGet(); } } }) @@ -96,7 +99,7 @@ class MessageChannelReactiveUtilsTests { compositeDisposable.dispose(); } - assertThat(channel.getMetrics().getSendCountLong()) + assertThat(sendCount.get()) .as("produced") .isLessThanOrEqualTo(Queues.SMALL_BUFFER_SIZE); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/flows/IntegrationFlowTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/flows/IntegrationFlowTests.java index 2f3312cc32..a9880d2710 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/flows/IntegrationFlowTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/flows/IntegrationFlowTests.java @@ -442,13 +442,7 @@ public class IntegrationFlowTests { @Test public void testNullChannelInTheEndOfFlow() { - this.nullChannel.setCountsEnabled(true); - this.flowWithNullChannelInput.send(new GenericMessage<>("foo")); - - assertThat(this.nullChannel.getSendCount()).isEqualTo(1); - - this.nullChannel.setCountsEnabled(false); } @Autowired @@ -461,13 +455,7 @@ public class IntegrationFlowTests { @Test public void testLocalNullChannel() { - this.localNullChannel.setCountsEnabled(true); - this.flowWithLocalNullChannelInput.send(new GenericMessage<>("foo")); - - assertThat(this.localNullChannel.getSendCount()).isEqualTo(1); - - assertThat(this.localNullChannel).isNotSameAs(this.nullChannel); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/graph/IntegrationGraphServerTests.java similarity index 95% rename from spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java rename to spring-integration-core/src/test/java/org/springframework/integration/graph/IntegrationGraphServerTests.java index d2217e9a99..9cf63b1718 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/graph/IntegrationGraphServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.integration.support.management.graph; +package org.springframework.integration.graph; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; @@ -53,8 +53,6 @@ import org.springframework.integration.endpoint.AbstractMessageSource; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.endpoint.MessageProducerSupport; import org.springframework.integration.endpoint.PollingConsumer; -import org.springframework.integration.graph.Graph; -import org.springframework.integration.graph.IntegrationGraphServer; import org.springframework.integration.json.JsonPathUtils; import org.springframework.integration.router.ExpressionEvaluatingRouter; import org.springframework.integration.router.HeaderValueRouter; @@ -74,6 +72,8 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import net.minidev.json.JSONArray; @@ -152,10 +152,18 @@ public class IntegrationGraphServerTests { this.testSource.receive(); this.expressionRouterInput.send(MessageBuilder.withPayload("foo").setHeader("foo", "fizChannel").build()); + jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'router')]"); + String routerJson = jsonArray.toJSONString(); + assertThat(routerJson).contains("\"deprecated\":\"stats are deprecated"); + + this.server.rebuild(); graph = this.server.getGraph(); baos = new ByteArrayOutputStream(); + objectMapper = new ObjectMapper(); objectMapper.enable(SerializationFeature.INDENT_OUTPUT); + objectMapper.registerModule(new SimpleModule().addSerializer(IntegrationNode.Stats.class, + NullSerializer.instance)); objectMapper.writeValue(baos, graph); // System . out . println(new String(baos.toByteArray())); @@ -170,8 +178,8 @@ public class IntegrationGraphServerTests { assertThat(links.size()).isEqualTo(37); jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'router')]"); - String routerJson = jsonArray.toJSONString(); - assertThat(routerJson).contains("\"deprecated\":\"stats are deprecated"); + routerJson = jsonArray.toJSONString(); + assertThat(routerJson).contains("\"stats\":null"); assertThat(routerJson).contains("\"sendTimers\":{\"successes\":{\"count\":4"); jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'toRouter')]"); String toRouterJson = jsonArray.toJSONString(); @@ -253,7 +261,7 @@ public class IntegrationGraphServerTests { @EnableIntegration @EnableIntegrationManagement @IntegrationComponentScan - @ImportResource("org/springframework/integration/support/management/graph/integration-graph-context.xml") + @ImportResource("org/springframework/integration/graph/integration-graph-context.xml") public static class Config { @Bean diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/integration-graph-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/graph/integration-graph-context.xml similarity index 100% rename from spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/integration-graph-context.xml rename to spring-integration-core/src/test/java/org/springframework/integration/graph/integration-graph-context.xml diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/DefaultMessageChannelMetricsTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/management/DefaultMessageChannelMetricsTests.java deleted file mode 100644 index 41c2b4c63c..0000000000 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/management/DefaultMessageChannelMetricsTests.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2017-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 static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; - -import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.messaging.Message; - -/** - * @author Ivan Krizsan - * @author Artem Bilan - */ -public class DefaultMessageChannelMetricsTests { - - protected static final int MESSAGE_COUNT = 10; - - protected static final long SEND_TIMEOUT = 1; - - @Test - public void errorCountWithCountsEnabledOnlySuccessTest() { - final QueueChannel theMessageChannel = new QueueChannel(); - theMessageChannel.setCountsEnabled(true); - - - for (int i = 0; i < MESSAGE_COUNT; i++) { - Message theInputMessage = - MessageBuilder.withPayload(Integer.toString(i)).build(); - theMessageChannel.send(theInputMessage, SEND_TIMEOUT); - } - - assertThat(theMessageChannel.getSendCount()).as("Message count should match number of sent messages") - .isEqualTo(MESSAGE_COUNT); - assertThat(theMessageChannel.getSendErrorCount()).as("Error count should indicate no errors").isEqualTo(0); - } - - @Test - public void errorCountWithCountsEnabledHalfErrorsTest() { - Message theInputMessage; - final QueueChannel theMessageChannel = new QueueChannel(MESSAGE_COUNT / 2); - theMessageChannel.setCountsEnabled(true); - - for (int i = 0; i < MESSAGE_COUNT; i++) { - theInputMessage = MessageBuilder.withPayload(Integer.toString(i)).build(); - theMessageChannel.send(theInputMessage, SEND_TIMEOUT); - } - - assertThat(theMessageChannel.getSendCount()).as("Message count should match number of sent messages") - .isEqualTo(MESSAGE_COUNT); - assertThat(theMessageChannel.getSendErrorCount()).as("Error count should indicate errors half the messages") - .isEqualTo(MESSAGE_COUNT / 2); - } - -} diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/IntegrationManagementConfigurerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/management/IntegrationManagementConfigurerTests.java index da1e1b0c65..3e20cee79e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/management/IntegrationManagementConfigurerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/management/IntegrationManagementConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2020 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. @@ -37,7 +37,6 @@ import org.springframework.integration.config.IntegrationManagementConfigurer; import org.springframework.integration.endpoint.AbstractMessageSource; import org.springframework.integration.handler.AbstractMessageHandler; import org.springframework.integration.router.RecipientListRouter; -import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.MessageChannel; /** @@ -94,8 +93,6 @@ public class IntegrationManagementConfigurerTests { AbstractMessageChannel channel = ctx.getBean("channel", AbstractMessageChannel.class); assertThat(channel.isCountsEnabled()).isTrue(); assertThat(channel.isStatsEnabled()).isTrue(); - assertThat(TestUtils.getPropertyValue(channel, "channelMetrics")) - .isInstanceOf(DefaultMessageChannelMetrics.class); channel = ctx.getBean("loggingOffChannel", AbstractMessageChannel.class); assertThat(channel.isLoggingEnabled()).isFalse(); ctx.close(); diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/PollableJmsChannel.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/PollableJmsChannel.java index 1a8c32642a..d8da654ce2 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/PollableJmsChannel.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/PollableJmsChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -21,7 +21,6 @@ import java.util.Deque; import java.util.List; import org.springframework.integration.channel.ExecutorChannelInterceptorAware; -import org.springframework.integration.support.management.PollableChannelManagement; import org.springframework.integration.support.management.metrics.CounterFacade; import org.springframework.integration.support.management.metrics.MetricsCaptor; import org.springframework.jms.core.JmsTemplate; @@ -39,8 +38,10 @@ import org.springframework.messaging.support.ExecutorChannelInterceptor; * * @since 2.0 */ +@SuppressWarnings("deprecation") public class PollableJmsChannel extends AbstractJmsChannel - implements PollableChannel, PollableChannelManagement, ExecutorChannelInterceptorAware { + implements PollableChannel, org.springframework.integration.support.management.PollableChannelManagement, + ExecutorChannelInterceptorAware { private String messageSelector; @@ -56,21 +57,45 @@ public class PollableJmsChannel extends AbstractJmsChannel this.messageSelector = messageSelector; } + /** + * Deprecated. + * @return receive count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getReceiveCount() { return getMetrics().getReceiveCount(); } + /** + * Deprecated. + * @return receive count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getReceiveCountLong() { return getMetrics().getReceiveCountLong(); } + /** + * Deprecated. + * @return receive error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public int getReceiveErrorCount() { return getMetrics().getReceiveErrorCount(); } + /** + * Deprecated. + * @return receive error count + * @deprecated in favor of Micrometer metrics. + */ + @Deprecated @Override public long getReceiveErrorCountLong() { return getMetrics().getReceiveErrorCountLong(); 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 3e330b0d02..c0e32b5e6f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -56,15 +56,9 @@ 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.LifecycleMessageSourceManagement; -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.MessageSourceManagement; -import org.springframework.integration.support.management.PollableChannelManagement; -import org.springframework.integration.support.management.RouterMetrics; import org.springframework.integration.support.management.TrackableComponent; -import org.springframework.integration.support.management.TrackableRouterMetrics; import org.springframework.integration.support.utils.PatternMatchUtils; import org.springframework.jmx.export.MBeanExporter; import org.springframework.jmx.export.UnableToRegisterMBeanException; @@ -740,8 +734,9 @@ public class IntegrationMBeanExporter extends MBeanExporter public long getChannelReceiveCountLong(String name) { org.springframework.integration.support.management.MessageChannelMetrics channelMetrics = getChannelMetrics(name); - if (channelMetrics instanceof PollableChannelManagement) { - return ((PollableChannelManagement) channelMetrics).getReceiveCountLong(); + if (channelMetrics instanceof org.springframework.integration.support.management.PollableChannelManagement) { + return ((org.springframework.integration.support.management.PollableChannelManagement) channelMetrics) + .getReceiveCountLong(); } return -1; } @@ -1036,11 +1031,12 @@ public class IntegrationMBeanExporter extends MBeanExporter org.springframework.integration.support.management.MessageHandlerMetrics result; if (monitor instanceof MappingMessageRouterManagement) { if (monitor instanceof TrackableComponent) { - result = new TrackableRouterMetrics(endpoint, + result = new org.springframework.integration.support.management.TrackableRouterMetrics(endpoint, (MappingMessageRouterManagement) monitor); } else { - result = new RouterMetrics(endpoint, (MappingMessageRouterManagement) monitor); + result = new org.springframework.integration.support.management.RouterMetrics(endpoint, + (MappingMessageRouterManagement) monitor); } } else { @@ -1163,16 +1159,19 @@ public class IntegrationMBeanExporter extends MBeanExporter org.springframework.integration.support.management.MessageSourceMetrics result; if (endpoint instanceof TrackableComponent) { if (monitor instanceof MessageSourceManagement) { - result = new LifecycleTrackableMessageSourceManagement((Lifecycle) endpoint, + result = new org.springframework.integration.support.management. + LifecycleTrackableMessageSourceManagement((Lifecycle) endpoint, (MessageSourceManagement) monitor); } else { - result = new LifecycleTrackableMessageSourceMetrics((Lifecycle) endpoint, monitor); + result = new org.springframework.integration.support.management. + LifecycleTrackableMessageSourceMetrics((Lifecycle) endpoint, monitor); } } else { if (monitor instanceof MessageSourceManagement) { - result = new LifecycleMessageSourceManagement((Lifecycle) endpoint, + result = new org.springframework.integration.support.management. + LifecycleMessageSourceManagement((Lifecycle) endpoint, (MessageSourceManagement) monitor); } else { diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/MBeanExporterParserTests-context.xml b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/MBeanExporterParserTests-context.xml index 31ed9b9925..5a40262d81 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/MBeanExporterParserTests-context.xml +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/MBeanExporterParserTests-context.xml @@ -25,8 +25,7 @@ default-counts-enabled="false" default-stats-enabled="false" counts-enabled-patterns="foo, !baz, ba*" - stats-enabled-patterns="fiz, buz" - metrics-factory="mf" /> + stats-enabled-patterns="fiz, buz" /> foo @@ -51,6 +50,4 @@ - - 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 3850a31d99..f99c239e41 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -22,35 +22,26 @@ import java.util.Properties; import javax.management.MBeanServer; -import org.assertj.core.data.Offset; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; -import org.springframework.integration.config.IntegrationManagementConfigurer; import org.springframework.integration.monitor.IntegrationMBeanExporter; -import org.springframework.integration.support.management.AbstractMessageChannelMetrics; -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.test.util.TestUtils; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * @author Mark Fisher * @author Oleg Zhurakousky * @author Gunnar Hillert * @author Gary Russell + * @author Artem Bilan * * @since 2.0 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext -@SuppressWarnings("deprecation") public class MBeanExporterParserTests { @Autowired @@ -67,89 +58,7 @@ public class MBeanExporterParserTests { assertThat(properties.containsKey("bar")).isTrue(); assertThat(exporter.getServer()).isEqualTo(server); assertThat(TestUtils.getPropertyValue(exporter, "namingStrategy")).isSameAs(context.getBean("keyNamer")); - 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); - org.springframework.integration.support.management.MessageHandlerMetrics handlerMetrics = - context.getBean("transformer.handler", - org.springframework.integration.support.management.MessageHandlerMetrics.class); - checkCustomized(handlerMetrics); - metrics = context.getBean("bar", org.springframework.integration.support.management.MessageChannelMetrics.class); - assertThat(metrics.isCountsEnabled()).isTrue(); - assertThat(metrics.isStatsEnabled()).isFalse(); - metrics = context.getBean("baz", org.springframework.integration.support.management.MessageChannelMetrics.class); - assertThat(metrics.isCountsEnabled()).isFalse(); - assertThat(metrics.isStatsEnabled()).isFalse(); - metrics = context.getBean("qux", org.springframework.integration.support.management.MessageChannelMetrics.class); - assertThat(metrics.isCountsEnabled()).isFalse(); - assertThat(metrics.isStatsEnabled()).isFalse(); - metrics = context.getBean("fiz", org.springframework.integration.support.management.MessageChannelMetrics.class); - assertThat(metrics.isCountsEnabled()).isTrue(); - assertThat(metrics.isStatsEnabled()).isTrue(); - metrics = context.getBean("buz", org.springframework.integration.support.management.MessageChannelMetrics.class); - assertThat(metrics.isCountsEnabled()).isTrue(); - assertThat(metrics.isStatsEnabled()).isTrue(); - metrics = context.getBean("!excluded", org.springframework.integration.support.management.MessageChannelMetrics.class); - assertThat(metrics.isCountsEnabled()).isFalse(); - assertThat(metrics.isStatsEnabled()).isFalse(); - checkCustomized(metrics); - 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(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)) - .isCloseTo(1000000., Offset.offset(.01)); - assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendErrorRate.window")).isEqualTo(30); - assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendErrorRate.period", Double.class)) - .isCloseTo(2000000., Offset.offset(.01)); - assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendErrorRate.lapse", Double.class)) - .isCloseTo(.001 / 120000, Offset.offset(.01)); - - assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendSuccessRatio.window")).isEqualTo(40); - assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.lapse", Double.class)) - .isCloseTo(.001 / 130000, Offset.offset(.01)); - - assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.window")).isEqualTo(50); - assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.period", Double.class)) - .isCloseTo(3000000., Offset.offset(.01)); - assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendRate.lapse", Double.class)) - .isCloseTo(.001 / 140000, Offset.offset(.01)); - } - - 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 org.springframework.integration.support.management.MetricsFactory { - - @Override - public AbstractMessageChannelMetrics createChannelMetrics(String name) { - return new DefaultMessageChannelMetrics(name, - 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 org.springframework.integration.support.management.ExponentialMovingAverage(20, 1000000.)); - } - - } - } diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/AggregatingMetricsTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/AggregatingMetricsTests.java deleted file mode 100644 index f2bda67564..0000000000 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/AggregatingMetricsTests.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2015-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.monitor; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.integration.channel.AbstractMessageChannel; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.handler.BridgeHandler; -import org.springframework.integration.handler.ServiceActivatingHandler; -import org.springframework.integration.support.management.AggregatingMessageChannelMetrics; -import org.springframework.integration.support.management.AggregatingMessageHandlerMetrics; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Gary Russell - * @since 4.2 - * - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class AggregatingMetricsTests { - - @Autowired - private MessageChannel input; - - @Autowired - private AbstractMessageChannel delay; - - @Autowired - private QueueChannel output; - - @Autowired - private BridgeHandler handler; - - @Autowired - private ServiceActivatingHandler delayer; - - @Test - public void testCounts() { - Message message = new GenericMessage("foo"); - int count = 2000; - for (int i = 0; i < count; i++) { - input.send(message); - } - assertThat(this.output.getQueueSize()).isEqualTo(count); - assertThat(this.output.getSendCount()).isEqualTo(count); - assertThat(this.output.getSendDuration().getCountLong()).isEqualTo(Long.valueOf(count / 1000).longValue()); - assertThat(this.handler.getHandleCount()).isEqualTo(count); - assertThat(this.handler.getDuration().getCountLong()).isEqualTo(Long.valueOf(count / 1000).longValue()); - } - - @Test - public void testElapsed() { - int sampleSize = 2; - this.delay.configureMetrics(new AggregatingMessageChannelMetrics("foo", sampleSize)); - this.delay.setStatsEnabled(true); - this.delayer.configureMetrics(new AggregatingMessageHandlerMetrics("bar", sampleSize)); - this.delayer.setStatsEnabled(true); - GenericMessage message = new GenericMessage("foo"); - int count = 4; - for (int i = 0; i < count; i++) { - this.delay.send(message); - } - assertThat(this.delay.getSendCount()).isEqualTo(count); - assertThat(this.delay.getSendDuration().getCount()).isEqualTo(count / sampleSize); - assertThat((int) this.delay.getMeanSendDuration() / sampleSize).isGreaterThanOrEqualTo(50); - assertThat(this.delayer.getHandleCount()).isEqualTo(count); - assertThat(this.delayer.getDuration().getCount()).isEqualTo(count / sampleSize); - assertThat((int) this.delayer.getMeanDuration() / sampleSize).isGreaterThanOrEqualTo(50); - } - - @Test @Ignore - public void perf() { - AggregatingMessageHandlerMetrics metrics = new AggregatingMessageHandlerMetrics(); - for (int i = 0; i < 100000000; i++) { - metrics.afterHandle(metrics.beforeHandle(), true); - } - } - -} 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 2170d9600d..58ba1fe256 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 @@ -1,5 +1,5 @@ /* - * Copyright 2009-2019 the original author or authors. + * Copyright 2009-2020 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. @@ -23,7 +23,6 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.support.context.NamedComponent; -import org.springframework.integration.support.management.BaseHandlerMetrics; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageDeliveryException; import org.springframework.messaging.PollableChannel; @@ -87,7 +86,8 @@ public class ChannelIntegrationTests { assertThat(messageChannelsMonitor.getChannelMetrics(intermediateChannelName)).isSameAs(intermediate); - BaseHandlerMetrics handlerMetrics = messageChannelsMonitor + @SuppressWarnings("deprecation") + org.springframework.integration.support.management.BaseHandlerMetrics handlerMetrics = messageChannelsMonitor .getHandlerMetrics("bridge"); assertThat(handlerMetrics.handleCount()).isEqualTo(3); 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 deleted file mode 100644 index d49877004d..0000000000 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MonitorTests.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2015-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.monitor; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; - -import org.springframework.beans.DirectFieldAccessor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.integration.channel.DirectChannel; -import org.springframework.integration.channel.NullChannel; -import org.springframework.integration.channel.PublishSubscribeChannel; -import org.springframework.integration.channel.QueueChannel; -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.test.util.TestUtils; -import org.springframework.messaging.Message; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Gary Russell - * @author Artem Bilan - * @since 4.2 - * - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class MonitorTests { - - @Autowired - private QueueChannel input; - - @Autowired - private DirectChannel next; - - @Autowired - private TestHandler handler; - - @Autowired - private TestSource source; - - @Autowired - private PublishSubscribeChannel pubsub; - - @Autowired - private QueueChannel output; - - @Autowired - private NullChannel nullChannel; - - - @SuppressWarnings("deprecation") - @Test - public void testStats() throws InterruptedException { - final CountDownLatch afterSendLatch = new CountDownLatch(1); - - DefaultMessageChannelMetrics channelMetrics = - TestUtils.getPropertyValue(this.next, "channelMetrics", DefaultMessageChannelMetrics.class); - channelMetrics = Mockito.spy(channelMetrics); - - Mockito.doAnswer(invocation -> { - Object result = invocation.callRealMethod(); - afterSendLatch.countDown(); - return result; - }).when(channelMetrics) - .afterSend(Mockito.any(org.springframework.integration.support.management.MetricsContext.class), - Mockito.eq(Boolean.TRUE)); - - new DirectFieldAccessor(this.next).setPropertyValue("channelMetrics", channelMetrics); - - MessagingTemplate messagingTemplate = new MessagingTemplate(this.input); - messagingTemplate.setReceiveTimeout(100000); - Integer active = messagingTemplate.convertSendAndReceive("foo", Integer.class); - assertThat(active.intValue()).isEqualTo(1); - assertThat(afterSendLatch.await(10, TimeUnit.SECONDS)).isTrue(); - assertThat(this.handler.getActiveCount()).isEqualTo(0); - assertThat(this.handler.getHandleCount()).isEqualTo(1); - assertThat(this.handler.getDuration().getMax()).isGreaterThan(99.0); - assertThat(this.handler.getDuration().getMax()).isLessThan(10000.0); - assertThat(this.input.getSendCount()).isEqualTo(1); - assertThat(this.input.getReceiveCount()).isEqualTo(1); - assertThat(this.next.getSendCount()).isEqualTo(1); - assertThat(this.next.getSendDuration().getMax()).isGreaterThan(99.0); - assertThat(this.next.getSendDuration().getMax()).isLessThan(10000.0); - Message fromInbound = this.output.receive(100000); - assertThat(fromInbound).isNotNull(); - assertThat(fromInbound.getPayload()).isEqualTo(0); - fromInbound = this.output.receive(10000); - assertThat(fromInbound).isNotNull(); - assertThat(fromInbound.getPayload()).isEqualTo(1); - assertThat(this.source.getMessageCount()).isGreaterThanOrEqualTo(2); - assertThat(this.nullChannel.getSendCount()).isGreaterThanOrEqualTo(2); - assertThat(this.pubsub.getSendCount()).isGreaterThanOrEqualTo(2); - } - - public static class TestHandler extends AbstractReplyProducingMessageHandler { - - @Override - protected Object handleRequestMessage(Message requestMessage) { - try { - Thread.sleep(100); - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - return getActiveCount(); - } - - } - - public static class TestSource extends AbstractMessageSource { - - @Override - public String getComponentType() { - return "foo"; - } - - @Override - protected Object doReceive() { - return getMessageCount(); - } - - } - -} diff --git a/src/reference/asciidoc/graph.adoc b/src/reference/asciidoc/graph.adoc index b36ec20b89..506c684e98 100644 --- a/src/reference/asciidoc/graph.adoc +++ b/src/reference/asciidoc/graph.adoc @@ -93,7 +93,18 @@ A Spring Integration application with only the default components would expose a NOTE: Version 5.2 has deprecated the legacy metrics in favor of Micrometer meters as discussed <<./metrics.adoc#metrics-management,Metrics Management>>. While not shown above, the legacy metrics (under the `stats` child node) will continue to appear in the graph, but with an extra child node `"deprecated" : "stats are deprecated in favor of sendTimers and receiveCounters"`. -The `providerFormatVersion` has been changed to 1.1 to reflect this change. + +With some JSON serializers, you can suppress the inclusion of legacy statistics using several techniques; for example, with Jackson, you can register a `SimpleModule` configured with a `NullSerializer` with the `ObjectMapper`: + +==== +[source, java] +---- +objectMapper.registerModule(new SimpleModule() + .addSerializer(IntegrationNode.Stats.class, NullSerializer.instance)); +---- +==== + +The resulting json contains `"stats" : null`. In the preceding example, the graph consists of three top-level elements.