Add remaining deprecations for legacy metrics

- add a module to suppress legacy metrics from the Integration Graph
- move graph tests package to match src/main

Fix missed deprecation and checkstyle.

More deprecations and remove GraphLegacyStatsNullModule.

* Revert GRAPH_VERSION.
* Fix JavaDocs warnings
* Fix `MBeanExporterParserTests`
This commit is contained in:
Gary Russell
2020-04-21 17:44:05 -04:00
committed by Artem Bilan
parent b06322787e
commit c2babe4ba2
46 changed files with 642 additions and 553 deletions

View File

@@ -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<AbstractMessageChannelMetrics>,
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<ChannelInterceptor> interceptorStack) {
if (interceptorStack != null) {
for (Iterator<ChannelInterceptor> iterator = interceptorStack.descendingIterator(); iterator.hasNext(); ) {
for (Iterator<ChannelInterceptor> iterator = interceptorStack.descendingIterator(); iterator
.hasNext(); ) {
ChannelInterceptor interceptor = iterator.next();
try {
interceptor.afterReceiveCompletion(message, channel, ex);

View File

@@ -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();

View File

@@ -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<AbstractMessageChannelMetrics>, 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();

View File

@@ -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<Message<?>> queue;

View File

@@ -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;

View File

@@ -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<AbstractMessageChannelMetrics>) 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<AbstractMessageHandlerMetrics>) 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);

View File

@@ -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<T> extends AbstractExpressionEvaluator
implements MessageSource<T>, org.springframework.integration.support.management.MessageSourceMetrics,
NamedComponent, BeanNameAware {
NamedComponent, BeanNameAware {
private final AtomicLong messageCount = new AtomicLong();
@@ -141,16 +141,33 @@ public abstract class AbstractMessageSource<T> 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<T> extends AbstractExpressionEvaluat
if (result == null) {
return null;
}
Message<?> message = null;
Message<?> message;
Map<String, Object> headers = evaluateHeaders();
if (result instanceof AbstractIntegrationMessageBuilder<?>) {
if (!CollectionUtils.isEmpty(headers)) {

View File

@@ -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.

View File

@@ -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<Message<?>> {
@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);

View File

@@ -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<AbstractMessageHandlerMetrics>,
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;

View File

@@ -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";

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {
/**

View File

@@ -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 {
/**

View File

@@ -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 {
}

View File

@@ -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<M extends ConfigurableMetrics> {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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();

View File

@@ -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")

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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

View File

@@ -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")

View File

@@ -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")

View File

@@ -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")

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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<String> 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<String> 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);
}
}

View File

@@ -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();