GH-2803: Deprecate legacy metrics
Resolves https://github.com/spring-projects/spring-integration/issues/2803 * Polishing - PR Comments * More PR Comments * Missed one comment
This commit is contained in:
committed by
Artem Bilan
parent
43d03c35b1
commit
6c3ffcb1d5
@@ -32,7 +32,6 @@ import org.aopalliance.aop.Advice;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.context.Lifecycle;
|
||||
@@ -92,7 +91,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageProducingHandler
|
||||
implements DiscardingMessageHandler, DisposableBean, ApplicationEventPublisherAware, Lifecycle {
|
||||
implements DiscardingMessageHandler, ApplicationEventPublisherAware, Lifecycle {
|
||||
|
||||
private final Comparator<Message<?>> sequenceNumberComparator = new MessageSequenceComparator();
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.integration.aggregator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
@@ -32,7 +31,7 @@ import org.springframework.integration.store.MessageGroup;
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class ExpressionEvaluatingMessageGroupProcessor extends AbstractAggregatingMessageGroupProcessor implements BeanFactoryAware {
|
||||
public class ExpressionEvaluatingMessageGroupProcessor extends AbstractAggregatingMessageGroupProcessor {
|
||||
|
||||
private final ExpressionEvaluatingMessageListProcessor processor;
|
||||
|
||||
|
||||
@@ -37,9 +37,6 @@ import org.springframework.integration.support.management.AbstractMessageChannel
|
||||
import org.springframework.integration.support.management.ConfigurableMetricsAware;
|
||||
import org.springframework.integration.support.management.DefaultMessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.MessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.MetricsContext;
|
||||
import org.springframework.integration.support.management.Statistics;
|
||||
import org.springframework.integration.support.management.TrackableComponent;
|
||||
import org.springframework.integration.support.management.metrics.MeterFacade;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
@@ -69,7 +66,8 @@ import org.springframework.util.StringUtils;
|
||||
@IntegrationManagedResource
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
implements MessageChannel, TrackableComponent, ChannelInterceptorAware, MessageChannelMetrics,
|
||||
implements MessageChannel, TrackableComponent, ChannelInterceptorAware,
|
||||
org.springframework.integration.support.management.MessageChannelMetrics,
|
||||
ConfigurableMetricsAware<AbstractMessageChannelMetrics> {
|
||||
|
||||
protected final ChannelInterceptorList interceptors; // NOSONAR
|
||||
@@ -117,8 +115,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMetricsCaptor(MetricsCaptor metricsCaptor) {
|
||||
this.metricsCaptor = metricsCaptor;
|
||||
public void registerMetricsCaptor(MetricsCaptor metricsCaptorToRegister) {
|
||||
this.metricsCaptor = metricsCaptorToRegister;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -335,17 +333,17 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getSendDuration() {
|
||||
public org.springframework.integration.support.management.Statistics getSendDuration() {
|
||||
return this.channelMetrics.getSendDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getSendRate() {
|
||||
public org.springframework.integration.support.management.Statistics getSendRate() {
|
||||
return this.channelMetrics.getSendRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getErrorRate() {
|
||||
public org.springframework.integration.support.management.Statistics getErrorRate() {
|
||||
return this.channelMetrics.getErrorRate();
|
||||
}
|
||||
|
||||
@@ -429,7 +427,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
Deque<ChannelInterceptor> interceptorStack = null;
|
||||
boolean sent = false;
|
||||
boolean metricsProcessed = false;
|
||||
MetricsContext metricsContext = null;
|
||||
org.springframework.integration.support.management.MetricsContext metricsContext = null;
|
||||
boolean countsAreEnabled = this.countsEnabled;
|
||||
ChannelInterceptorList interceptorList = this.interceptors;
|
||||
AbstractMessageChannelMetrics metrics = this.channelMetrics;
|
||||
|
||||
@@ -27,8 +27,6 @@ import org.springframework.integration.support.management.AbstractMessageChannel
|
||||
import org.springframework.integration.support.management.ConfigurableMetricsAware;
|
||||
import org.springframework.integration.support.management.DefaultMessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.MessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.Statistics;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
import org.springframework.integration.support.management.metrics.TimerFacade;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -47,7 +45,9 @@ import org.springframework.util.Assert;
|
||||
* @author Artyem Bilan
|
||||
*/
|
||||
@IntegrationManagedResource
|
||||
public class NullChannel implements PollableChannel, MessageChannelMetrics,
|
||||
@SuppressWarnings("deprecation")
|
||||
public class NullChannel implements PollableChannel,
|
||||
org.springframework.integration.support.management.MessageChannelMetrics,
|
||||
ConfigurableMetricsAware<AbstractMessageChannelMetrics>, BeanNameAware, NamedComponent {
|
||||
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
@@ -211,17 +211,17 @@ public class NullChannel implements PollableChannel, MessageChannelMetrics,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getSendDuration() {
|
||||
public org.springframework.integration.support.management.Statistics getSendDuration() {
|
||||
return this.channelMetrics.getSendDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getSendRate() {
|
||||
public org.springframework.integration.support.management.Statistics getSendRate() {
|
||||
return this.channelMetrics.getSendRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getErrorRate() {
|
||||
public org.springframework.integration.support.management.Statistics getErrorRate() {
|
||||
return this.channelMetrics.getErrorRate();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.messaging.support.ExecutorChannelInterceptor;
|
||||
|
||||
/**
|
||||
@@ -51,7 +50,7 @@ import org.springframework.messaging.support.ExecutorChannelInterceptor;
|
||||
* @since 4.2
|
||||
*/
|
||||
public abstract class ThreadStatePropagationChannelInterceptor<S>
|
||||
implements ChannelInterceptor, ExecutorChannelInterceptor {
|
||||
implements ExecutorChannelInterceptor {
|
||||
|
||||
@Override
|
||||
public final Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
/**
|
||||
* Enables default configuring of management in Spring Integration components in an existing application.
|
||||
@@ -53,9 +54,29 @@ public @interface EnableIntegrationManagement {
|
||||
* Defaults to no components, unless JMX is enabled in which case, defaults to all
|
||||
* components. Overrides {@link #defaultCountsEnabled()} for matching bean names.
|
||||
* @return the patterns.
|
||||
* @deprecated in favor of 'metersEnabled'.
|
||||
*/
|
||||
@Deprecated
|
||||
@AliasFor("metersEnabled")
|
||||
String[] countsEnabled() default "*";
|
||||
|
||||
/**
|
||||
* A list of simple patterns for component names for which message counts will be
|
||||
* enabled (defaults to '*'). Enables message
|
||||
* counting (`sendCount`, `errorCount`, `receiveCount`) for those components that
|
||||
* support counters (channels, message handlers, etc). This is the initial setting
|
||||
* only, individual components can have counts enabled/disabled at runtime. May be
|
||||
* overridden by an entry in {@link #statsEnabled() statsEnabled} which is additional
|
||||
* functionality over simple counts. If a pattern starts with `!`, counts are disabled
|
||||
* for matches. For components that match multiple patterns, the first pattern wins.
|
||||
* Disabling counts at runtime also disables stats.
|
||||
* Defaults to no components, unless JMX is enabled in which case, defaults to all
|
||||
* components. Overrides {@link #defaultCountsEnabled()} for matching bean names.
|
||||
* @return the patterns.
|
||||
*/
|
||||
@AliasFor("countsEnabled")
|
||||
String[] metersEnabled() default "*";
|
||||
|
||||
/**
|
||||
* A list of simple patterns for component names for which message statistics will be
|
||||
* enabled (response times, rates etc), as well as counts (a positive match here
|
||||
@@ -72,7 +93,11 @@ public @interface EnableIntegrationManagement {
|
||||
* Defaults to no components, unless JMX is enabled in which case, defaults to all
|
||||
* components.
|
||||
* @return the patterns.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
String[] statsEnabled() default "*";
|
||||
|
||||
/**
|
||||
@@ -86,7 +111,11 @@ public @interface EnableIntegrationManagement {
|
||||
* The default setting for enabling statistics when a bean name is not matched by
|
||||
* {@link #statsEnabled() statsEnabled}.
|
||||
* @return the value; false by default, or true when JMX is enabled.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
String defaultStatsEnabled() default "false";
|
||||
|
||||
/**
|
||||
@@ -113,7 +142,11 @@ public @interface EnableIntegrationManagement {
|
||||
* The bean name of a {@code MetricsFactory}. The {@code DefaultMetricsFactory} is used
|
||||
* if omitted.
|
||||
* @return the bean name.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
String metricsFactory() default "";
|
||||
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public class IntegrationManagementConfiguration implements ImportAware, Environm
|
||||
"@EnableIntegrationManagement is not present on importing class " + importMetadata.getClassName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Bean(name = IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME)
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public IntegrationManagementConfigurer managementConfigurer() {
|
||||
@@ -90,17 +91,18 @@ public class IntegrationManagementConfiguration implements ImportAware, Environm
|
||||
String pattern = this.environment.resolvePlaceholders(managedComponent);
|
||||
patterns.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(pattern)));
|
||||
}
|
||||
configurer.setEnabledCountsPatterns(patterns.toArray(new String[patterns.size()]));
|
||||
configurer.setEnabledCountsPatterns(patterns.toArray(new String[0]));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void setupStatsEnabledNamePatterns(IntegrationManagementConfigurer configurer) {
|
||||
List<String> patterns = new ArrayList<String>();
|
||||
List<String> patterns = new ArrayList<>();
|
||||
String[] statsEnabled = this.attributes.getStringArray("statsEnabled");
|
||||
for (String managedComponent : statsEnabled) {
|
||||
String pattern = this.environment.resolvePlaceholders(managedComponent);
|
||||
patterns.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(pattern)));
|
||||
}
|
||||
configurer.setEnabledStatsPatterns(patterns.toArray(new String[patterns.size()]));
|
||||
configurer.setEnabledStatsPatterns(patterns.toArray(new String[0]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,14 +34,8 @@ import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.support.management.AbstractMessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.AbstractMessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.ConfigurableMetricsAware;
|
||||
import org.springframework.integration.support.management.DefaultMetricsFactory;
|
||||
import org.springframework.integration.support.management.IntegrationManagement;
|
||||
import org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides;
|
||||
import org.springframework.integration.support.management.MessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.MessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.MessageSourceMetrics;
|
||||
import org.springframework.integration.support.management.MessageSourceMetricsConfigurer;
|
||||
import org.springframework.integration.support.management.MetricsFactory;
|
||||
import org.springframework.integration.support.management.PollableChannelManagement;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
import org.springframework.integration.support.management.micrometer.MicrometerMetricsCaptor;
|
||||
@@ -64,6 +58,7 @@ import org.springframework.util.StringUtils;
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class IntegrationManagementConfigurer
|
||||
implements SmartInitializingSingleton, ApplicationContextAware, BeanNameAware,
|
||||
DestructionAwareBeanPostProcessor {
|
||||
@@ -72,13 +67,18 @@ public class IntegrationManagementConfigurer
|
||||
|
||||
public static final String MANAGEMENT_CONFIGURER_NAME = "integrationManagementConfigurer";
|
||||
|
||||
private final Map<String, MessageChannelMetrics> channelsByName = new HashMap<>();
|
||||
private final Map<String, org.springframework.integration.support.management.MessageChannelMetrics>
|
||||
channelsByName = new HashMap<>();
|
||||
|
||||
private final Map<String, MessageHandlerMetrics> handlersByName = new HashMap<>();
|
||||
private final Map<String, org.springframework.integration.support.management.MessageHandlerMetrics>
|
||||
handlersByName = new HashMap<>();
|
||||
|
||||
private final Map<String, MessageSourceMetrics> sourcesByName = new HashMap<>();
|
||||
private final Map<String, org.springframework.integration.support.management.MessageSourceMetrics>
|
||||
sourcesByName = new HashMap<>();
|
||||
|
||||
private final Map<String, MessageSourceMetricsConfigurer> sourceConfigurers = new HashMap<>();
|
||||
private final Map<String,
|
||||
org.springframework.integration.support.management.MessageSourceMetricsConfigurer>
|
||||
sourceConfigurers = new HashMap<>();
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class IntegrationManagementConfigurer
|
||||
|
||||
private Boolean defaultStatsEnabled = false;
|
||||
|
||||
private MetricsFactory metricsFactory;
|
||||
private org.springframework.integration.support.management.MetricsFactory metricsFactory;
|
||||
|
||||
private String metricsFactoryBeanName;
|
||||
|
||||
@@ -115,11 +115,15 @@ public class IntegrationManagementConfigurer
|
||||
/**
|
||||
* Set a metrics factory.
|
||||
* Has a precedence over {@link #metricsFactoryBeanName}.
|
||||
* Defaults to {@link DefaultMetricsFactory}.
|
||||
* Defaults to {@link org.springframework.integration.support.management.DefaultMetricsFactory}.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @param metricsFactory the factory.
|
||||
* @since 4.2
|
||||
*/
|
||||
public void setMetricsFactory(MetricsFactory metricsFactory) {
|
||||
@Deprecated
|
||||
public void setMetricsFactory(org.springframework.integration.support.management.MetricsFactory metricsFactory) {
|
||||
this.metricsFactory = metricsFactory;
|
||||
}
|
||||
|
||||
@@ -127,8 +131,12 @@ public class IntegrationManagementConfigurer
|
||||
* Set a metrics factory bean name.
|
||||
* Is used if {@link #metricsFactory} isn't specified.
|
||||
* @param metricsFactory the factory.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @since 4.2
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMetricsFactoryBeanName(String metricsFactory) {
|
||||
this.metricsFactoryBeanName = metricsFactory;
|
||||
}
|
||||
@@ -164,8 +172,12 @@ public class IntegrationManagementConfigurer
|
||||
* 'foo' in {@link #setEnabledCountsPatterns(String[]) enabledCountsPatterns}. For
|
||||
* components that match multiple patterns, the first pattern wins. Enabling stats at
|
||||
* runtime also enables counts.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @param enabledStatsPatterns the patterns.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setEnabledStatsPatterns(String[] enabledStatsPatterns) {
|
||||
Assert.notEmpty(enabledStatsPatterns, "enabledStatsPatterns must not be empty");
|
||||
this.enabledStatsPatterns = Arrays.copyOf(enabledStatsPatterns, enabledStatsPatterns.length);
|
||||
@@ -188,11 +200,23 @@ public class IntegrationManagementConfigurer
|
||||
* Set whether managed components maintain message statistics by default.
|
||||
* Defaults to false, unless an Integration MBean Exporter is configured.
|
||||
* @param defaultStatsEnabled true to enable.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setDefaultStatsEnabled(Boolean defaultStatsEnabled) {
|
||||
this.defaultStatsEnabled = defaultStatsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if stats are enabled by default.
|
||||
* @return the stats enabled.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
public Boolean getDefaultStatsEnabled() {
|
||||
return this.defaultStatsEnabled;
|
||||
}
|
||||
@@ -234,18 +258,22 @@ public class IntegrationManagementConfigurer
|
||||
registerComponentGauges();
|
||||
}
|
||||
if (this.metricsFactory == null && StringUtils.hasText(this.metricsFactoryBeanName)) {
|
||||
this.metricsFactory = this.applicationContext.getBean(this.metricsFactoryBeanName, MetricsFactory.class);
|
||||
this.metricsFactory = this.applicationContext.getBean(this.metricsFactoryBeanName,
|
||||
org.springframework.integration.support.management.MetricsFactory.class);
|
||||
}
|
||||
if (this.metricsFactory == null) {
|
||||
Map<String, MetricsFactory> factories = this.applicationContext.getBeansOfType(MetricsFactory.class);
|
||||
Map<String, org.springframework.integration.support.management.MetricsFactory>
|
||||
factories = this.applicationContext
|
||||
.getBeansOfType(org.springframework.integration.support.management.MetricsFactory.class);
|
||||
if (factories.size() == 1) {
|
||||
this.metricsFactory = factories.values().iterator().next();
|
||||
}
|
||||
}
|
||||
if (this.metricsFactory == null) {
|
||||
this.metricsFactory = new DefaultMetricsFactory();
|
||||
this.metricsFactory = new org.springframework.integration.support.management.DefaultMetricsFactory();
|
||||
}
|
||||
this.sourceConfigurers.putAll(this.applicationContext.getBeansOfType(MessageSourceMetricsConfigurer.class));
|
||||
this.sourceConfigurers.putAll(this.applicationContext.getBeansOfType(
|
||||
org.springframework.integration.support.management.MessageSourceMetricsConfigurer.class));
|
||||
Map<String, IntegrationManagement> managed = this.applicationContext
|
||||
.getBeansOfType(IntegrationManagement.class);
|
||||
for (Entry<String, IntegrationManagement> entry : managed.entrySet()) {
|
||||
@@ -284,44 +312,47 @@ public class IntegrationManagementConfigurer
|
||||
|
||||
@Override
|
||||
public boolean requiresDestruction(Object bean) {
|
||||
return bean instanceof MessageChannelMetrics ||
|
||||
bean instanceof MessageHandlerMetrics ||
|
||||
bean instanceof MessageSourceMetrics;
|
||||
return bean instanceof org.springframework.integration.support.management.MessageChannelMetrics ||
|
||||
bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics ||
|
||||
bean instanceof org.springframework.integration.support.management.MessageSourceMetrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof MessageChannelMetrics) {
|
||||
this.channelsByName.remove(beanName);
|
||||
public void postProcessBeforeDestruction(Object bean, String nameOfBean) throws BeansException {
|
||||
if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) {
|
||||
this.channelsByName.remove(nameOfBean);
|
||||
}
|
||||
else if (bean instanceof MessageHandlerMetrics) {
|
||||
if (this.handlersByName.remove(beanName) == null) {
|
||||
this.handlersByName.remove(beanName + ".handler");
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics) {
|
||||
if (this.handlersByName.remove(nameOfBean) == null) {
|
||||
this.handlersByName.remove(nameOfBean + ".handler");
|
||||
}
|
||||
}
|
||||
else if (bean instanceof MessageSourceMetrics) {
|
||||
if (this.sourcesByName.remove(beanName) == null) {
|
||||
this.sourcesByName.remove(beanName + ".source");
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics) {
|
||||
if (this.sourcesByName.remove(nameOfBean) == null) {
|
||||
this.sourcesByName.remove(nameOfBean + ".source");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Object doConfigureMetrics(Object bean, String name) {
|
||||
if (bean instanceof MessageChannelMetrics) {
|
||||
configureChannelMetrics(name, (MessageChannelMetrics) bean);
|
||||
if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) {
|
||||
configureChannelMetrics(name, (org.springframework.integration.support.management.MessageChannelMetrics) bean);
|
||||
}
|
||||
else if (bean instanceof MessageHandlerMetrics) {
|
||||
configureHandlerMetrics(name, (MessageHandlerMetrics) bean);
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics) {
|
||||
configureHandlerMetrics(name, (org.springframework.integration.support.management.MessageHandlerMetrics) bean);
|
||||
}
|
||||
else if (bean instanceof MessageSourceMetrics) {
|
||||
configureSourceMetrics(name, (MessageSourceMetrics) bean);
|
||||
this.sourceConfigurers.values().forEach(c -> c.configure((MessageSourceMetrics) bean, name));
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics) {
|
||||
configureSourceMetrics(name, (org.springframework.integration.support.management.MessageSourceMetrics) bean);
|
||||
this.sourceConfigurers.values().forEach(c -> c
|
||||
.configure((org.springframework.integration.support.management.MessageSourceMetrics) bean, name));
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void configureChannelMetrics(String name, MessageChannelMetrics bean) {
|
||||
private void configureChannelMetrics(String name,
|
||||
org.springframework.integration.support.management.MessageChannelMetrics bean) {
|
||||
|
||||
AbstractMessageChannelMetrics metrics;
|
||||
if (bean instanceof PollableChannelManagement) {
|
||||
metrics = this.metricsFactory.createPollableChannelMetrics(name);
|
||||
@@ -358,7 +389,8 @@ public class IntegrationManagementConfigurer
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void configureHandlerMetrics(String name, MessageHandlerMetrics bean) {
|
||||
private void configureHandlerMetrics(String name,
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics bean) {
|
||||
AbstractMessageHandlerMetrics metrics = this.metricsFactory.createHandlerMetrics(name);
|
||||
Assert.state(metrics != null, "'metrics' must not be null");
|
||||
ManagementOverrides overrides = bean.getOverrides();
|
||||
@@ -389,7 +421,9 @@ public class IntegrationManagementConfigurer
|
||||
this.handlersByName.put(bean.getManagedName() != null ? bean.getManagedName() : name, bean);
|
||||
}
|
||||
|
||||
private void configureSourceMetrics(String name, MessageSourceMetrics bean) {
|
||||
private void configureSourceMetrics(String name,
|
||||
org.springframework.integration.support.management.MessageSourceMetrics bean) {
|
||||
|
||||
Boolean enabled = PatternMatchUtils.smartMatch(name, this.enabledCountsPatterns);
|
||||
if (enabled != null) {
|
||||
bean.setCountsEnabled(enabled);
|
||||
@@ -420,18 +454,18 @@ public class IntegrationManagementConfigurer
|
||||
}
|
||||
|
||||
public String[] getChannelNames() {
|
||||
return this.channelsByName.keySet().toArray(new String[this.channelsByName.size()]);
|
||||
return this.channelsByName.keySet().toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String[] getHandlerNames() {
|
||||
return this.handlersByName.keySet().toArray(new String[this.handlersByName.size()]);
|
||||
return this.handlersByName.keySet().toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String[] getSourceNames() {
|
||||
return this.sourcesByName.keySet().toArray(new String[this.sourcesByName.size()]);
|
||||
return this.sourcesByName.keySet().toArray(new String[0]);
|
||||
}
|
||||
|
||||
public MessageChannelMetrics getChannelMetrics(String name) {
|
||||
public org.springframework.integration.support.management.MessageChannelMetrics getChannelMetrics(String name) {
|
||||
if (this.channelsByName.containsKey(name)) {
|
||||
return this.channelsByName.get(name);
|
||||
}
|
||||
@@ -441,7 +475,7 @@ public class IntegrationManagementConfigurer
|
||||
return null;
|
||||
}
|
||||
|
||||
public MessageHandlerMetrics getHandlerMetrics(String name) {
|
||||
public org.springframework.integration.support.management.MessageHandlerMetrics getHandlerMetrics(String name) {
|
||||
if (this.handlersByName.containsKey(name)) {
|
||||
return this.handlersByName.get(name);
|
||||
}
|
||||
@@ -455,7 +489,7 @@ public class IntegrationManagementConfigurer
|
||||
return null;
|
||||
}
|
||||
|
||||
public MessageSourceMetrics getSourceMetrics(String name) {
|
||||
public org.springframework.integration.support.management.MessageSourceMetrics getSourceMetrics(String name) {
|
||||
if (this.sourcesByName.containsKey(name)) {
|
||||
return this.sourcesByName.get(name);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ import org.springframework.util.StringUtils;
|
||||
* @since 5.0
|
||||
*/
|
||||
public final class RouterSpec<K, R extends AbstractMappingMessageRouter>
|
||||
extends AbstractRouterSpec<RouterSpec<K, R>, R>
|
||||
implements ComponentsRegistration {
|
||||
extends AbstractRouterSpec<RouterSpec<K, R>, R> {
|
||||
|
||||
private final RouterMappingProvider mappingProvider;
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.springframework.integration.expression.ExpressionEvalMap;
|
||||
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.MessageSourceMetrics;
|
||||
import org.springframework.integration.support.management.metrics.CounterFacade;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
import org.springframework.integration.util.AbstractExpressionEvaluator;
|
||||
@@ -43,9 +42,11 @@ import org.springframework.util.CollectionUtils;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@IntegrationManagedResource
|
||||
public abstract class AbstractMessageSource<T> extends AbstractExpressionEvaluator
|
||||
implements MessageSource<T>, MessageSourceMetrics, NamedComponent, BeanNameAware {
|
||||
implements MessageSource<T>, org.springframework.integration.support.management.MessageSourceMetrics,
|
||||
NamedComponent, BeanNameAware {
|
||||
|
||||
private final AtomicLong messageCount = new AtomicLong();
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.integration.endpoint;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -32,8 +31,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MethodInvokingMessageSource extends AbstractMessageSource<Object>
|
||||
implements InitializingBean, Lifecycle {
|
||||
public class MethodInvokingMessageSource extends AbstractMessageSource<Object> implements Lifecycle {
|
||||
|
||||
private volatile Object object;
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PollingConsumer extends AbstractPollingEndpoint implements Integrat
|
||||
this.inputChannel = inputChannel;
|
||||
this.handler = handler;
|
||||
if (this.inputChannel instanceof ExecutorChannelInterceptorAware) {
|
||||
this.channelInterceptors = ((ExecutorChannelInterceptorAware) this.inputChannel).getChannelInterceptors();
|
||||
this.channelInterceptors = ((ExecutorChannelInterceptorAware) this.inputChannel).getInterceptors();
|
||||
}
|
||||
else {
|
||||
this.channelInterceptors = null;
|
||||
|
||||
@@ -44,8 +44,6 @@ import org.springframework.integration.support.MessageBuilderFactory;
|
||||
import org.springframework.integration.support.MutableMessageBuilder;
|
||||
import org.springframework.integration.support.converter.SimpleMessageConverter;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.MessageSourceMetrics;
|
||||
import org.springframework.integration.support.management.TrackableComponent;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -71,9 +69,11 @@ import reactor.core.publisher.Mono;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@IntegrationManagedResource
|
||||
public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
implements TrackableComponent, MessageSourceMetrics {
|
||||
implements org.springframework.integration.support.management.TrackableComponent,
|
||||
org.springframework.integration.support.management.MessageSourceMetrics {
|
||||
|
||||
private static final long DEFAULT_TIMEOUT = 1000L;
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.integration.graph;
|
||||
|
||||
import org.springframework.integration.support.management.MessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.Statistics;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
@@ -28,19 +26,22 @@ import org.springframework.messaging.MessageChannel;
|
||||
* @since 4.3
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MessageChannelNode extends IntegrationNode {
|
||||
|
||||
public MessageChannelNode(int nodeId, String name, MessageChannel channel) {
|
||||
super(nodeId, name, channel, channel instanceof MessageChannelMetrics
|
||||
? new Stats((MessageChannelMetrics) channel) : new IntegrationNode.Stats());
|
||||
super(nodeId, name, channel,
|
||||
channel instanceof org.springframework.integration.support.management.MessageChannelMetrics
|
||||
? new Stats((org.springframework.integration.support.management.MessageChannelMetrics) channel)
|
||||
: new IntegrationNode.Stats());
|
||||
}
|
||||
|
||||
|
||||
public static final class Stats extends IntegrationNode.Stats {
|
||||
|
||||
private final MessageChannelMetrics channel;
|
||||
private final org.springframework.integration.support.management.MessageChannelMetrics channel;
|
||||
|
||||
Stats(MessageChannelMetrics channel) {
|
||||
Stats(org.springframework.integration.support.management.MessageChannelMetrics channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@@ -97,15 +98,15 @@ public class MessageChannelNode extends IntegrationNode {
|
||||
return this.channel.getStandardDeviationSendDuration();
|
||||
}
|
||||
|
||||
public Statistics getSendDuration() {
|
||||
public org.springframework.integration.support.management.Statistics getSendDuration() {
|
||||
return this.channel.getSendDuration();
|
||||
}
|
||||
|
||||
public Statistics getSendRate() {
|
||||
public org.springframework.integration.support.management.Statistics getSendRate() {
|
||||
return this.channel.getSendRate();
|
||||
}
|
||||
|
||||
public Statistics getErrorRate() {
|
||||
public org.springframework.integration.support.management.Statistics getErrorRate() {
|
||||
return this.channel.getErrorRate();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.integration.graph;
|
||||
|
||||
import org.springframework.integration.support.management.MessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.Statistics;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
|
||||
/**
|
||||
@@ -28,13 +26,16 @@ import org.springframework.messaging.MessageHandler;
|
||||
* @since 4.3
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MessageHandlerNode extends EndpointNode {
|
||||
|
||||
private final String input;
|
||||
|
||||
public MessageHandlerNode(int nodeId, String name, MessageHandler handler, String input, String output) {
|
||||
super(nodeId, name, handler, output, handler instanceof MessageHandlerMetrics
|
||||
? new Stats((MessageHandlerMetrics) handler) : new IntegrationNode.Stats());
|
||||
super(nodeId, name, handler, output,
|
||||
handler instanceof org.springframework.integration.support.management.MessageHandlerMetrics
|
||||
? new Stats((org.springframework.integration.support.management.MessageHandlerMetrics) handler)
|
||||
: new IntegrationNode.Stats());
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
@@ -44,9 +45,9 @@ public class MessageHandlerNode extends EndpointNode {
|
||||
|
||||
public static final class Stats extends IntegrationNode.Stats {
|
||||
|
||||
private final MessageHandlerMetrics handler;
|
||||
private final org.springframework.integration.support.management.MessageHandlerMetrics handler;
|
||||
|
||||
Stats(MessageHandlerMetrics handler) {
|
||||
Stats(org.springframework.integration.support.management.MessageHandlerMetrics handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@@ -87,7 +88,7 @@ public class MessageHandlerNode extends EndpointNode {
|
||||
return this.handler.getActiveCountLong();
|
||||
}
|
||||
|
||||
public Statistics getDuration() {
|
||||
public org.springframework.integration.support.management.Statistics getDuration() {
|
||||
return this.handler.getDuration();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.integration.graph;
|
||||
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.support.management.MessageSourceMetrics;
|
||||
|
||||
/**
|
||||
* Represents a message source.
|
||||
@@ -27,19 +26,23 @@ import org.springframework.integration.support.management.MessageSourceMetrics;
|
||||
* @since 4.3
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MessageSourceNode extends ErrorCapableEndpointNode {
|
||||
|
||||
public MessageSourceNode(int nodeId, String name, MessageSource<?> messageSource, String output, String errors) {
|
||||
super(nodeId, name, messageSource, output, errors, messageSource instanceof MessageSourceMetrics
|
||||
? new Stats((MessageSourceMetrics) messageSource) : new IntegrationNode.Stats());
|
||||
super(nodeId, name, messageSource, output, errors,
|
||||
messageSource instanceof org.springframework.integration.support.management.MessageSourceMetrics
|
||||
? new Stats(
|
||||
(org.springframework.integration.support.management.MessageSourceMetrics) messageSource)
|
||||
: new IntegrationNode.Stats());
|
||||
}
|
||||
|
||||
|
||||
public static final class Stats extends IntegrationNode.Stats {
|
||||
|
||||
private final MessageSourceMetrics source;
|
||||
private final org.springframework.integration.support.management.MessageSourceMetrics source;
|
||||
|
||||
Stats(MessageSourceMetrics source) {
|
||||
Stats(org.springframework.integration.support.management.MessageSourceMetrics source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,6 @@ import org.springframework.integration.support.management.AbstractMessageHandler
|
||||
import org.springframework.integration.support.management.ConfigurableMetricsAware;
|
||||
import org.springframework.integration.support.management.DefaultMessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.MessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.MetricsContext;
|
||||
import org.springframework.integration.support.management.Statistics;
|
||||
import org.springframework.integration.support.management.TrackableComponent;
|
||||
import org.springframework.integration.support.management.metrics.MeterFacade;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
@@ -55,9 +52,12 @@ import reactor.core.CoreSubscriber;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@IntegrationManagedResource
|
||||
public abstract class AbstractMessageHandler extends IntegrationObjectSupport
|
||||
implements MessageHandler, MessageHandlerMetrics, ConfigurableMetricsAware<AbstractMessageHandlerMetrics>,
|
||||
implements MessageHandler,
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics,
|
||||
ConfigurableMetricsAware<AbstractMessageHandlerMetrics>,
|
||||
TrackableComponent, Orderable, CoreSubscriber<Message<?>> {
|
||||
|
||||
private final ManagementOverrides managementOverrides = new ManagementOverrides();
|
||||
@@ -147,7 +147,7 @@ public abstract class AbstractMessageHandler extends IntegrationObjectSupport
|
||||
if (this.loggingEnabled && this.logger.isDebugEnabled()) {
|
||||
this.logger.debug(this + " received message: " + message);
|
||||
}
|
||||
MetricsContext start = null;
|
||||
org.springframework.integration.support.management.MetricsContext start = null;
|
||||
boolean countsAreEnabled = this.countsEnabled;
|
||||
AbstractMessageHandlerMetrics metrics = this.handlerMetrics;
|
||||
SampleFacade sample = null;
|
||||
@@ -280,7 +280,7 @@ public abstract class AbstractMessageHandler extends IntegrationObjectSupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getDuration() {
|
||||
public org.springframework.integration.support.management.Statistics getDuration() {
|
||||
return this.handlerMetrics.getDuration();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.integration.resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -44,7 +43,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ResourceRetrievingMessageSource extends AbstractMessageSource<Resource[]>
|
||||
implements ApplicationContextAware, InitializingBean {
|
||||
implements ApplicationContextAware {
|
||||
|
||||
private final String pattern;
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.filter.ExpressionEvaluatingSelector;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
@@ -73,8 +72,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Liujiong
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class RecipientListRouter extends AbstractMessageRouter
|
||||
implements InitializingBean, RecipientListRouterManagement {
|
||||
public class RecipientListRouter extends AbstractMessageRouter implements RecipientListRouterManagement {
|
||||
|
||||
private volatile Queue<Recipient> recipients = new ConcurrentLinkedQueue<>();
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public abstract class AbstractMessageChannelMetrics implements ConfigurableMetri
|
||||
* @return the context to be used in a subsequent {@link #afterSend(MetricsContext, boolean)}
|
||||
* call.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract MetricsContext beforeSend();
|
||||
|
||||
/**
|
||||
@@ -70,7 +71,7 @@ public abstract class AbstractMessageChannelMetrics implements ConfigurableMetri
|
||||
* @param context the context.
|
||||
* @param result true for success, false otherwise.
|
||||
*/
|
||||
public abstract void afterSend(MetricsContext context, boolean result);
|
||||
public abstract void afterSend(@SuppressWarnings("deprecation") MetricsContext context, boolean result);
|
||||
|
||||
/**
|
||||
* Reset all counters/statistics.
|
||||
@@ -101,10 +102,13 @@ public abstract class AbstractMessageChannelMetrics implements ConfigurableMetri
|
||||
|
||||
public abstract double getStandardDeviationSendDuration();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract Statistics getSendDuration();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract Statistics getSendRate();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract Statistics getErrorRate();
|
||||
|
||||
public abstract void afterReceive();
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class AbstractMessageHandlerMetrics implements ConfigurableMetrics {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -24,6 +24,7 @@ package org.springframework.integration.support.management;
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AggregatingMessageChannelMetrics extends DefaultMessageChannelMetrics {
|
||||
|
||||
private static final int DEFAULT_SAMPLE_SIZE = 1000;
|
||||
|
||||
@@ -25,6 +25,7 @@ package org.springframework.integration.support.management;
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AggregatingMessageHandlerMetrics extends DefaultMessageHandlerMetrics {
|
||||
|
||||
private static final int DEFAULT_SAMPLE_SIZE = 1000;
|
||||
|
||||
@@ -16,16 +16,18 @@
|
||||
|
||||
package org.springframework.integration.support.management;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Implementation that returns aggregating metrics.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AggregatingMetricsFactory implements MetricsFactory {
|
||||
|
||||
private final int sampleSize;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* Primary interface for channels that provide metrics.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 5.2
|
||||
*
|
||||
*/
|
||||
public interface BaseChannelMetrics extends IntegrationStatsManagement {
|
||||
|
||||
/**
|
||||
* @return the number of successful sends
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Send Count")
|
||||
long sendCount();
|
||||
|
||||
/**
|
||||
* @return the number of failed sends (either throwing an exception or rejected by the channel)
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Send Error Count")
|
||||
long sendErrorCount();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @since 5.2
|
||||
*
|
||||
*/
|
||||
public interface BaseHandlerMetrics extends IntegrationStatsManagement {
|
||||
|
||||
/**
|
||||
* @return the number of successful handler calls
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Execution Count")
|
||||
long handleCount();
|
||||
|
||||
/**
|
||||
* @return the number of failed handler calls
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Error Count")
|
||||
long errorCount();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.support.management;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @since 5.2
|
||||
*
|
||||
*/
|
||||
public interface BaseSourceMetrics extends IntegrationManagement {
|
||||
|
||||
/**
|
||||
* The number of successful message receptions.
|
||||
* @return the count.
|
||||
*/
|
||||
long messageCount();
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultMessageChannelMetrics extends AbstractMessageChannelMetrics {
|
||||
|
||||
public static final long ONE_SECOND_SECONDS = 1;
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultMessageHandlerMetrics extends AbstractMessageHandlerMetrics {
|
||||
|
||||
private static final int DEFAULT_MOVING_AVERAGE_WINDOW = 10;
|
||||
|
||||
@@ -21,11 +21,16 @@ package org.springframework.integration.support.management;
|
||||
|
||||
/**
|
||||
* Default implementation.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultMetricsFactory implements MetricsFactory {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,11 +32,16 @@ import java.util.List;
|
||||
* those trends can be approximately reflected. For performance reasons, the calculation is performed on retrieval,
|
||||
* {@code window * 5} samples are retained meaning that the earliest retained value contributes just 0.5% to the
|
||||
* sum.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverage {
|
||||
|
||||
private volatile long count;
|
||||
|
||||
@@ -37,11 +37,16 @@ import java.util.List;
|
||||
* For performance reasons, the calculation is performed on retrieval,
|
||||
* {@code window * 5} samples are retained meaning that the earliest retained value contributes just 0.5% to the
|
||||
* sum.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Steven Swor
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverageRate {
|
||||
|
||||
private volatile double min = Double.MAX_VALUE;
|
||||
|
||||
@@ -38,11 +38,16 @@ import java.util.List;
|
||||
* For performance reasons, the calculation is performed on retrieval,
|
||||
* {@code window * 5} samples are retained meaning that the earliest retained value contributes just 0.5% to the
|
||||
* sum.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Steven Swor
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverageRatio {
|
||||
|
||||
private volatile double t0;
|
||||
|
||||
@@ -21,23 +21,32 @@ import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
|
||||
/**
|
||||
* A {@link MessageHandlerMetrics} that exposes in addition the {@link Lifecycle} interface. The lifecycle methods can
|
||||
* be used to stop and start polling endpoints, for instance, in a live system.
|
||||
* A {@link MessageHandlerMetrics} that exposes in addition the {@link Lifecycle}
|
||||
* interface. The lifecycle methods can be used to stop and start polling endpoints, for
|
||||
* instance, in a live system.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
@IntegrationManagedResource
|
||||
public class LifecycleMessageHandlerMetrics implements MessageHandlerMetrics, Lifecycle,
|
||||
ConfigurableMetricsAware<AbstractMessageHandlerMetrics> {
|
||||
@SuppressWarnings("deprecation")
|
||||
public class LifecycleMessageHandlerMetrics implements
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics, Lifecycle,
|
||||
ConfigurableMetricsAware<AbstractMessageHandlerMetrics> {
|
||||
|
||||
private final Lifecycle lifecycle;
|
||||
|
||||
protected final MessageHandlerMetrics delegate;
|
||||
protected final org.springframework.integration.support.management.MessageHandlerMetrics delegate;
|
||||
|
||||
|
||||
public LifecycleMessageHandlerMetrics(Lifecycle lifecycle, MessageHandlerMetrics delegate) {
|
||||
public LifecycleMessageHandlerMetrics(Lifecycle lifecycle,
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics delegate) {
|
||||
|
||||
this.lifecycle = lifecycle;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.context.Lifecycle;
|
||||
* @since 5.0
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class LifecycleMessageSourceManagement extends LifecycleMessageSourceMetrics implements MessageSourceManagement {
|
||||
|
||||
public LifecycleMessageSourceManagement(Lifecycle lifecycle, MessageSourceManagement delegate) {
|
||||
|
||||
@@ -23,13 +23,16 @@ import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
/**
|
||||
* A {@link MessageSourceMetrics} that exposes in addition the {@link Lifecycle} interface.
|
||||
* The lifecycle methods can be used to start and stop polling endpoints, for instance, in a live system.
|
||||
*
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
@IntegrationManagedResource
|
||||
public class LifecycleMessageSourceMetrics implements MessageSourceMetrics, Lifecycle {
|
||||
|
||||
|
||||
@@ -21,12 +21,16 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Adds {@link TrackableComponent}.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
@Deprecated
|
||||
@IntegrationManagedResource
|
||||
public class LifecycleTrackableMessageHandlerMetrics extends LifecycleMessageHandlerMetrics
|
||||
implements TrackableComponent {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.context.Lifecycle;
|
||||
* @since 5.0
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class LifecycleTrackableMessageSourceManagement extends LifecycleTrackableMessageSourceMetrics
|
||||
implements MessageSourceManagement {
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@IntegrationManagedResource
|
||||
public class LifecycleTrackableMessageSourceMetrics extends LifecycleMessageSourceMetrics
|
||||
implements TrackableComponent {
|
||||
|
||||
@@ -20,14 +20,18 @@ import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* Interface for all message channel monitors containing accessors for various useful metrics that are generic for all
|
||||
* channel types.
|
||||
* Interface for all message channel monitors containing accessors for various useful
|
||||
* metrics that are generic for all channel types.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface MessageChannelMetrics extends IntegrationStatsManagement {
|
||||
@Deprecated
|
||||
public interface MessageChannelMetrics extends BaseChannelMetrics {
|
||||
|
||||
/**
|
||||
* @return the number of successful sends
|
||||
@@ -42,6 +46,12 @@ public interface MessageChannelMetrics extends IntegrationStatsManagement {
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Send Count")
|
||||
long getSendCountLong();
|
||||
|
||||
|
||||
@Override
|
||||
default long sendCount() {
|
||||
return getSendCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of failed sends (either throwing an exception or rejected by the channel)
|
||||
*/
|
||||
@@ -55,6 +65,11 @@ public interface MessageChannelMetrics extends IntegrationStatsManagement {
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Send Error Count")
|
||||
long getSendErrorCountLong();
|
||||
|
||||
@Override
|
||||
default long sendErrorCount() {
|
||||
return getSendErrorCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time in milliseconds since the last send
|
||||
*/
|
||||
|
||||
@@ -22,9 +22,13 @@ import org.springframework.jmx.support.MetricType;
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface MessageHandlerMetrics extends IntegrationStatsManagement {
|
||||
@Deprecated
|
||||
public interface MessageHandlerMetrics extends BaseHandlerMetrics {
|
||||
|
||||
/**
|
||||
* @return the number of successful handler calls
|
||||
@@ -39,6 +43,12 @@ public interface MessageHandlerMetrics extends IntegrationStatsManagement {
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Execution Count")
|
||||
long getHandleCountLong();
|
||||
|
||||
|
||||
@Override
|
||||
default long handleCount() {
|
||||
return getHandleCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of failed handler calls
|
||||
*/
|
||||
@@ -52,6 +62,11 @@ public interface MessageHandlerMetrics extends IntegrationStatsManagement {
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Error Count")
|
||||
long getErrorCountLong();
|
||||
|
||||
@Override
|
||||
default long errorCount() {
|
||||
return getErrorCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mean handler duration (milliseconds)
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
* @since 5.0
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@IntegrationManagedResource
|
||||
public interface MessageSourceManagement extends MessageSourceMetrics {
|
||||
|
||||
|
||||
@@ -23,13 +23,16 @@ import org.springframework.jmx.support.MetricType;
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface MessageSourceMetrics extends IntegrationManagement {
|
||||
@Deprecated
|
||||
public interface MessageSourceMetrics extends BaseSourceMetrics {
|
||||
|
||||
/**
|
||||
* @return the number of successful handler calls
|
||||
* @return the number of successful message receptions.
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Message Source Message Count")
|
||||
int getMessageCount();
|
||||
@@ -41,6 +44,11 @@ public interface MessageSourceMetrics extends IntegrationManagement {
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Message Source Message Count")
|
||||
long getMessageCountLong();
|
||||
|
||||
@Override
|
||||
default long messageCount() {
|
||||
return getMessageCountLong();
|
||||
}
|
||||
|
||||
void setManagedName(String name);
|
||||
|
||||
String getManagedName();
|
||||
|
||||
@@ -18,12 +18,17 @@ package org.springframework.integration.support.management;
|
||||
|
||||
/**
|
||||
* Perform additional configuration on {@link MessageSourceMetrics}.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 5.0.2
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@FunctionalInterface
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface MessageSourceMetricsConfigurer {
|
||||
|
||||
void configure(MessageSourceMetrics metrics, String beanName);
|
||||
|
||||
@@ -19,11 +19,13 @@ package org.springframework.integration.support.management;
|
||||
/**
|
||||
* Interface representing an opaque object containing state between initiating an
|
||||
* event and concluding it.
|
||||
*
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MetricsContext {
|
||||
|
||||
}
|
||||
|
||||
@@ -19,11 +19,14 @@ package org.springframework.integration.support.management;
|
||||
/**
|
||||
* Factories implementing this interface provide metric objects for message channels and
|
||||
* message handlers.
|
||||
*
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MetricsFactory {
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.jmx.support.MetricType;
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
public interface PollableChannelManagement extends MessageChannelMetrics {
|
||||
public interface PollableChannelManagement extends PollableChannelMetrics {
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Count")
|
||||
int getReceiveCount();
|
||||
@@ -34,10 +34,20 @@ public interface PollableChannelManagement extends MessageChannelMetrics {
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Count")
|
||||
long getReceiveCountLong();
|
||||
|
||||
@Override
|
||||
default long receiveCount() {
|
||||
return getReceiveCountLong();
|
||||
}
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Error Count")
|
||||
int getReceiveErrorCount();
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Error Count")
|
||||
long getReceiveErrorCountLong();
|
||||
|
||||
@Override
|
||||
default long receiveErrorCount() {
|
||||
return getReceiveErrorCountLong();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @since 5.2
|
||||
*
|
||||
*/
|
||||
public interface PollableChannelMetrics extends IntegrationStatsManagement {
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Receive Count")
|
||||
long receiveCount();
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Receive Error Count")
|
||||
long receiveErrorCount();
|
||||
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import org.springframework.context.Lifecycle;
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RouterMetrics extends LifecycleMessageHandlerMetrics implements MappingMessageRouterManagement {
|
||||
|
||||
private final MappingMessageRouterManagement router;
|
||||
|
||||
@@ -17,10 +17,16 @@
|
||||
package org.springframework.integration.support.management;
|
||||
|
||||
/**
|
||||
* Statistics.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public class Statistics {
|
||||
|
||||
private final long count;
|
||||
|
||||
@@ -148,7 +148,7 @@ public class GlobalChannelInterceptorTests {
|
||||
ConfigurableListableBeanFactory beanFactory = this.applicationContext.getBeanFactory();
|
||||
beanFactory.initializeBean(testChannel, "testChannel");
|
||||
|
||||
List<ChannelInterceptor> channelInterceptors = testChannel.getChannelInterceptors();
|
||||
List<ChannelInterceptor> channelInterceptors = testChannel.getInterceptors();
|
||||
|
||||
assertThat(channelInterceptors.size()).isEqualTo(2);
|
||||
assertThat(channelInterceptors.get(0)).isInstanceOf(SampleInterceptor.class);
|
||||
|
||||
@@ -87,7 +87,7 @@ public class GlobalWireTapTests {
|
||||
|
||||
assertThat(this.wiretapAll2.receive(1)).isNull();
|
||||
|
||||
assertThat(this.channel.getChannelInterceptors().size()).isEqualTo(4);
|
||||
assertThat(this.channel.getInterceptors().size()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -53,15 +53,15 @@ public class ImplicitConsumerChannelTests {
|
||||
@Test
|
||||
public void testImplicit() {
|
||||
// used to fail to load AC (no channel 'bar')
|
||||
List<ChannelInterceptor> barInterceptors = bar.getChannelInterceptors();
|
||||
List<ChannelInterceptor> barInterceptors = bar.getInterceptors();
|
||||
assertThat(barInterceptors.size()).isEqualTo(2);
|
||||
assertThat(barInterceptors.get(0)).isInstanceOfAny(Interceptor1.class, Interceptor2.class);
|
||||
assertThat(barInterceptors.get(1)).isInstanceOfAny(Interceptor1.class, Interceptor2.class);
|
||||
List<ChannelInterceptor> fooInterceptors = foo.getChannelInterceptors();
|
||||
List<ChannelInterceptor> fooInterceptors = foo.getInterceptors();
|
||||
assertThat(fooInterceptors.size()).isEqualTo(2);
|
||||
assertThat(fooInterceptors.get(0)).isInstanceOfAny(WireTap.class, Interceptor2.class);
|
||||
assertThat(fooInterceptors.get(1)).isInstanceOfAny(WireTap.class, Interceptor2.class);
|
||||
List<ChannelInterceptor> bazInterceptors = baz.getChannelInterceptors();
|
||||
List<ChannelInterceptor> bazInterceptors = baz.getInterceptors();
|
||||
assertThat(bazInterceptors.size()).isEqualTo(2);
|
||||
assertThat(bazInterceptors.get(0)).isInstanceOfAny(WireTap.class, Interceptor1.class);
|
||||
assertThat(bazInterceptors.get(1)).isInstanceOfAny(WireTap.class, Interceptor1.class);
|
||||
|
||||
@@ -472,8 +472,8 @@ public class EnableIntegrationTests {
|
||||
child.refresh();
|
||||
AbstractMessageChannel foo = child.getBean("foo", AbstractMessageChannel.class);
|
||||
ChannelInterceptor baz = child.getBean("baz", ChannelInterceptor.class);
|
||||
assertThat(foo.getChannelInterceptors().contains(baz)).isTrue();
|
||||
assertThat(this.output.getChannelInterceptors().contains(baz)).isFalse();
|
||||
assertThat(foo.getInterceptors().contains(baz)).isTrue();
|
||||
assertThat(this.output.getInterceptors().contains(baz)).isFalse();
|
||||
child.close();
|
||||
}
|
||||
|
||||
@@ -485,8 +485,8 @@ public class EnableIntegrationTests {
|
||||
child.refresh();
|
||||
AbstractMessageChannel foo = child.getBean("foo", AbstractMessageChannel.class);
|
||||
ChannelInterceptor baz = child.getBean("baz", ChannelInterceptor.class);
|
||||
assertThat(foo.getChannelInterceptors().contains(baz)).isTrue();
|
||||
assertThat(this.output.getChannelInterceptors().contains(baz)).isFalse();
|
||||
assertThat(foo.getInterceptors().contains(baz)).isTrue();
|
||||
assertThat(this.output.getInterceptors().contains(baz)).isFalse();
|
||||
child.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanCreationNotAllowedException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
@@ -574,8 +573,7 @@ public class ManualFlowTests {
|
||||
|
||||
}
|
||||
|
||||
private final class BeanFactoryHandler extends AbstractReplyProducingMessageHandler
|
||||
implements DisposableBean {
|
||||
private final class BeanFactoryHandler extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
@Autowired
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.StopWatch;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@Ignore("Very sensitive to the time. Don't forget to test after some changes.")
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverageRateTests {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ExponentialMovingAverageRateTests.class);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.integration.test.util.TestUtils;
|
||||
* @author Steven Swor
|
||||
*/
|
||||
@Ignore("Very sensitive to the time. Don't forget to test after some changes.")
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverageRatioTests {
|
||||
|
||||
private final ExponentialMovingAverageRatio history = new ExponentialMovingAverageRatio(0.5, 10, true);
|
||||
@@ -69,7 +70,7 @@ public class ExponentialMovingAverageRatioTests {
|
||||
* time.
|
||||
*/
|
||||
double timeSinceLastMeasurement = history.getTimeSinceLastMeasurement();
|
||||
assertThat(timeSinceLastMeasurement).isGreaterThan((double) (sleepTime / 100));
|
||||
assertThat(timeSinceLastMeasurement).isGreaterThan(sleepTime / 100);
|
||||
assertThat(timeSinceLastMeasurement).isLessThanOrEqualTo(1.5 * sleepTime / 100);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.junit.Test;
|
||||
* @author Gary Russell
|
||||
*/
|
||||
@Ignore("Very sensitive to the time. Don't forget to test after some changes.")
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverageTests {
|
||||
|
||||
private final ExponentialMovingAverage history = new ExponentialMovingAverage(10);
|
||||
|
||||
@@ -99,6 +99,7 @@ public class IntegrationMBeanExportConfiguration implements ImportAware, Environ
|
||||
"@EnableIntegrationMBeanExport is not present on importing class " + importMetadata.getClassName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Bean(name = MBEAN_EXPORTER_NAME)
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public IntegrationMBeanExporter mbeanExporter() {
|
||||
|
||||
@@ -55,20 +55,13 @@ import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.handler.AbstractMessageProducingHandler;
|
||||
import org.springframework.integration.history.MessageHistoryConfigurer;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
import org.springframework.integration.support.management.LifecycleMessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.LifecycleMessageSourceManagement;
|
||||
import org.springframework.integration.support.management.LifecycleMessageSourceMetrics;
|
||||
import org.springframework.integration.support.management.LifecycleTrackableMessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.LifecycleTrackableMessageSourceManagement;
|
||||
import org.springframework.integration.support.management.LifecycleTrackableMessageSourceMetrics;
|
||||
import org.springframework.integration.support.management.MappingMessageRouterManagement;
|
||||
import org.springframework.integration.support.management.MessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.MessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.MessageSourceManagement;
|
||||
import org.springframework.integration.support.management.MessageSourceMetrics;
|
||||
import org.springframework.integration.support.management.PollableChannelManagement;
|
||||
import org.springframework.integration.support.management.RouterMetrics;
|
||||
import org.springframework.integration.support.management.Statistics;
|
||||
import org.springframework.integration.support.management.TrackableComponent;
|
||||
import org.springframework.integration.support.management.TrackableRouterMetrics;
|
||||
import org.springframework.integration.support.utils.PatternMatchUtils;
|
||||
@@ -114,6 +107,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Meherzad Lahewala
|
||||
*/
|
||||
@ManagedResource
|
||||
@SuppressWarnings("deprecation")
|
||||
public class IntegrationMBeanExporter extends MBeanExporter
|
||||
implements ApplicationContextAware, DestructionAwareBeanPostProcessor {
|
||||
|
||||
@@ -129,17 +123,22 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
|
||||
private final Map<Object, AtomicLong> anonymousSourceCounters = new HashMap<>();
|
||||
|
||||
private final Set<MessageHandlerMetrics> handlers = new HashSet<>();
|
||||
private final Set<org.springframework.integration.support.management.MessageHandlerMetrics>
|
||||
handlers = new HashSet<>();
|
||||
|
||||
private final Set<MessageSourceMetrics> sources = new HashSet<>();
|
||||
private final Set<org.springframework.integration.support.management.MessageSourceMetrics>
|
||||
sources = new HashSet<>();
|
||||
|
||||
private final Set<Lifecycle> inboundLifecycleMessageProducers = new HashSet<>();
|
||||
|
||||
private final Set<MessageChannelMetrics> channels = new HashSet<>();
|
||||
private final Set<org.springframework.integration.support.management.MessageChannelMetrics>
|
||||
channels = new HashSet<>();
|
||||
|
||||
private final Map<String, MessageChannelMetrics> allChannelsByName = new HashMap<>();
|
||||
private final Map<String, org.springframework.integration.support.management.MessageChannelMetrics>
|
||||
allChannelsByName = new HashMap<>();
|
||||
|
||||
private final Map<String, MessageSourceMetrics> allSourcesByName = new HashMap<>();
|
||||
private final Map<String, org.springframework.integration.support.management.MessageSourceMetrics>
|
||||
allSourcesByName = new HashMap<>();
|
||||
|
||||
private final Map<Object, String> endpointsByMonitor = new HashMap<>();
|
||||
|
||||
@@ -256,11 +255,14 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
}
|
||||
|
||||
private void populateMessageHandlers() {
|
||||
Map<String, MessageHandlerMetrics> messageHandlers =
|
||||
this.applicationContext.getBeansOfType(MessageHandlerMetrics.class);
|
||||
for (Entry<String, MessageHandlerMetrics> entry : messageHandlers.entrySet()) {
|
||||
Map<String, org.springframework.integration.support.management.MessageHandlerMetrics> messageHandlers =
|
||||
this.applicationContext
|
||||
.getBeansOfType(org.springframework.integration.support.management.MessageHandlerMetrics.class);
|
||||
for (Entry<String, org.springframework.integration.support.management.MessageHandlerMetrics> entry
|
||||
: messageHandlers.entrySet()) {
|
||||
|
||||
String beanName = entry.getKey();
|
||||
MessageHandlerMetrics bean = entry.getValue();
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics bean = entry.getValue();
|
||||
if (this.handlerInAnonymousWrapper(bean) != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Skipping " + beanName + " because it wraps another handler");
|
||||
@@ -269,30 +271,33 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
}
|
||||
// If the handler is proxied, we have to extract the target to expose as an MBean.
|
||||
// The MetadataMBeanInfoAssembler does not support JDK dynamic proxies.
|
||||
MessageHandlerMetrics monitor = (MessageHandlerMetrics) extractTarget(bean);
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics monitor =
|
||||
(org.springframework.integration.support.management.MessageHandlerMetrics) extractTarget(bean);
|
||||
this.handlers.add(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
private void populateMessageSources() {
|
||||
this.applicationContext.getBeansOfType(MessageSourceMetrics.class)
|
||||
this.applicationContext.getBeansOfType(
|
||||
org.springframework.integration.support.management.MessageSourceMetrics.class)
|
||||
.values()
|
||||
.stream()
|
||||
// If the channel is proxied, we have to extract the target to expose as an MBean.
|
||||
// The MetadataMBeanInfoAssembler does not support JDK dynamic proxies.
|
||||
.map(this::extractTarget)
|
||||
.map(MessageSourceMetrics.class::cast)
|
||||
.map(org.springframework.integration.support.management.MessageSourceMetrics.class::cast)
|
||||
.forEach(this.sources::add);
|
||||
}
|
||||
|
||||
private void populateMessageChannels() {
|
||||
this.applicationContext.getBeansOfType(MessageChannelMetrics.class)
|
||||
this.applicationContext.getBeansOfType(
|
||||
org.springframework.integration.support.management.MessageChannelMetrics.class)
|
||||
.values()
|
||||
.stream()
|
||||
// If the channel is proxied, we have to extract the target to expose as an MBean.
|
||||
// The MetadataMBeanInfoAssembler does not support JDK dynamic proxies.
|
||||
.map(this::extractTarget)
|
||||
.map(MessageChannelMetrics.class::cast)
|
||||
.map(org.springframework.integration.support.management.MessageChannelMetrics.class::cast)
|
||||
.forEach(this.channels::add);
|
||||
}
|
||||
|
||||
@@ -324,8 +329,9 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (this.singletonsInstantiated) {
|
||||
try {
|
||||
if (bean instanceof MessageChannelMetrics) {
|
||||
MessageChannelMetrics monitor = (MessageChannelMetrics) extractTarget(bean);
|
||||
if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) {
|
||||
org.springframework.integration.support.management.MessageChannelMetrics monitor =
|
||||
(org.springframework.integration.support.management.MessageChannelMetrics) extractTarget(bean);
|
||||
this.channels.add(monitor);
|
||||
registerChannel(monitor);
|
||||
this.runtimeBeans.add(bean);
|
||||
@@ -349,9 +355,9 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
if (bean instanceof IntegrationConsumer) {
|
||||
IntegrationConsumer integrationConsumer = (IntegrationConsumer) bean;
|
||||
MessageHandler handler = integrationConsumer.getHandler();
|
||||
if (handler instanceof MessageHandlerMetrics) {
|
||||
MessageHandlerMetrics messageHandlerMetrics =
|
||||
(MessageHandlerMetrics) extractTarget(handler);
|
||||
if (handler instanceof org.springframework.integration.support.management.MessageHandlerMetrics) {
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics messageHandlerMetrics =
|
||||
(org.springframework.integration.support.management.MessageHandlerMetrics) extractTarget(handler);
|
||||
registerHandler(messageHandlerMetrics);
|
||||
this.handlers.add(messageHandlerMetrics);
|
||||
this.runtimeBeans.add(messageHandlerMetrics);
|
||||
@@ -361,9 +367,10 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
else if (bean instanceof SourcePollingChannelAdapter) {
|
||||
SourcePollingChannelAdapter pollingChannelAdapter = (SourcePollingChannelAdapter) bean;
|
||||
MessageSource<?> messageSource = pollingChannelAdapter.getMessageSource();
|
||||
if (messageSource instanceof MessageSourceMetrics) {
|
||||
MessageSourceMetrics messageSourceMetrics =
|
||||
(MessageSourceMetrics) extractTarget(messageSource);
|
||||
if (messageSource instanceof org.springframework.integration.support.management.MessageSourceMetrics) {
|
||||
org.springframework.integration.support.management.MessageSourceMetrics messageSourceMetrics =
|
||||
(org.springframework.integration.support.management.MessageSourceMetrics)
|
||||
extractTarget(messageSource);
|
||||
registerSource(messageSourceMetrics);
|
||||
this.sources.add(messageSourceMetrics);
|
||||
this.runtimeBeans.add(messageSourceMetrics);
|
||||
@@ -384,9 +391,9 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
|
||||
@Override
|
||||
public boolean requiresDestruction(Object bean) {
|
||||
return bean instanceof MessageChannelMetrics || // NOSONAR
|
||||
bean instanceof MessageHandlerMetrics ||
|
||||
bean instanceof MessageSourceMetrics ||
|
||||
return bean instanceof org.springframework.integration.support.management.MessageChannelMetrics || // NOSONAR
|
||||
bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics ||
|
||||
bean instanceof org.springframework.integration.support.management.MessageSourceMetrics ||
|
||||
(bean instanceof MessageProducer && bean instanceof Lifecycle) ||
|
||||
bean instanceof AbstractEndpoint;
|
||||
}
|
||||
@@ -403,18 +410,20 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
else {
|
||||
|
||||
this.endpointsByMonitor.remove(bean);
|
||||
if (bean instanceof MessageChannelMetrics) {
|
||||
if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) {
|
||||
this.channels.remove(bean);
|
||||
this.allChannelsByName.remove(((NamedComponent) bean).getComponentName());
|
||||
}
|
||||
else if (bean instanceof MessageHandlerMetrics) {
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics) {
|
||||
this.handlers.remove(bean);
|
||||
this.endpointNames.remove(((NamedComponent) bean).getComponentName());
|
||||
}
|
||||
else if (bean instanceof MessageSourceMetrics) {
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics) {
|
||||
this.sources.remove(bean);
|
||||
this.endpointNames.remove(((NamedComponent) bean).getComponentName());
|
||||
String managedName = ((MessageSourceMetrics) bean).getManagedName();
|
||||
String managedName =
|
||||
((org.springframework.integration.support.management.MessageSourceMetrics) bean)
|
||||
.getManagedName();
|
||||
this.allSourcesByName.remove(managedName);
|
||||
}
|
||||
}
|
||||
@@ -489,13 +498,13 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
for (MessageChannelMetrics monitor : this.channels) {
|
||||
for (org.springframework.integration.support.management.MessageChannelMetrics monitor : this.channels) {
|
||||
logger.info("Summary on shutdown: " + monitor);
|
||||
}
|
||||
for (MessageHandlerMetrics monitor : this.handlers) {
|
||||
for (org.springframework.integration.support.management.MessageHandlerMetrics monitor : this.handlers) {
|
||||
logger.info("Summary on shutdown: " + monitor);
|
||||
}
|
||||
for (MessageSourceMetrics monitor : this.sources) {
|
||||
for (org.springframework.integration.support.management.MessageSourceMetrics monitor : this.sources) {
|
||||
logger.info("Summary on shutdown: " + monitor);
|
||||
}
|
||||
}
|
||||
@@ -554,7 +563,9 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
*/
|
||||
@ManagedOperation
|
||||
public void stopMessageSources() {
|
||||
for (MessageSourceMetrics sourceMetrics : this.allSourcesByName.values()) {
|
||||
for (org.springframework.integration.support.management.MessageSourceMetrics sourceMetrics
|
||||
: this.allSourcesByName.values()) {
|
||||
|
||||
if (sourceMetrics instanceof Lifecycle) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Stopping message source " + sourceMetrics);
|
||||
@@ -588,7 +599,7 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
@ManagedOperation
|
||||
public void stopActiveChannels() {
|
||||
// Stop any "active" channels (JMS etc).
|
||||
for (MessageChannelMetrics metrics : this.allChannelsByName.values()) {
|
||||
for (org.springframework.integration.support.management.MessageChannelMetrics metrics : this.allChannelsByName.values()) {
|
||||
MessageChannel channel = (MessageChannel) metrics;
|
||||
if (channel instanceof Lifecycle) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
@@ -653,7 +664,7 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Active Handler Count")
|
||||
public long getActiveHandlerCountLong() {
|
||||
int count = 0;
|
||||
for (MessageHandlerMetrics monitor : this.handlers) {
|
||||
for (org.springframework.integration.support.management.MessageHandlerMetrics monitor : this.handlers) {
|
||||
count += monitor.getActiveCountLong();
|
||||
}
|
||||
return count;
|
||||
@@ -673,12 +684,12 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
return this.managementConfigurer.getChannelNames();
|
||||
}
|
||||
|
||||
public MessageHandlerMetrics getHandlerMetrics(String name) {
|
||||
public org.springframework.integration.support.management.MessageHandlerMetrics getHandlerMetrics(String name) {
|
||||
return this.managementConfigurer.getHandlerMetrics(name);
|
||||
}
|
||||
|
||||
public Statistics getHandlerDuration(String name) {
|
||||
MessageHandlerMetrics handlerMetrics = getHandlerMetrics(name);
|
||||
public org.springframework.integration.support.management.Statistics getHandlerDuration(String name) {
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics handlerMetrics = getHandlerMetrics(name);
|
||||
return handlerMetrics != null ? handlerMetrics.getDuration() : null;
|
||||
}
|
||||
|
||||
@@ -687,7 +698,7 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
return this.managementConfigurer.getSourceNames();
|
||||
}
|
||||
|
||||
public MessageSourceMetrics getSourceMetrics(String name) {
|
||||
public org.springframework.integration.support.management.MessageSourceMetrics getSourceMetrics(String name) {
|
||||
return this.managementConfigurer.getSourceMetrics(name);
|
||||
}
|
||||
|
||||
@@ -696,11 +707,11 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
}
|
||||
|
||||
public long getSourceMessageCountLong(String name) {
|
||||
MessageSourceMetrics sourceMetrics = getSourceMetrics(name);
|
||||
org.springframework.integration.support.management.MessageSourceMetrics sourceMetrics = getSourceMetrics(name);
|
||||
return sourceMetrics != null ? sourceMetrics.getMessageCountLong() : -1;
|
||||
}
|
||||
|
||||
public MessageChannelMetrics getChannelMetrics(String name) {
|
||||
public org.springframework.integration.support.management.MessageChannelMetrics getChannelMetrics(String name) {
|
||||
return this.managementConfigurer.getChannelMetrics(name);
|
||||
}
|
||||
|
||||
@@ -709,7 +720,8 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
}
|
||||
|
||||
public long getChannelSendCountLong(String name) {
|
||||
MessageChannelMetrics channelMetrics = getChannelMetrics(name);
|
||||
org.springframework.integration.support.management.MessageChannelMetrics channelMetrics =
|
||||
getChannelMetrics(name);
|
||||
return channelMetrics != null ? channelMetrics.getSendCountLong() : -1;
|
||||
}
|
||||
|
||||
@@ -718,7 +730,7 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
}
|
||||
|
||||
public long getChannelSendErrorCountLong(String name) {
|
||||
MessageChannelMetrics channelMetrics = getChannelMetrics(name);
|
||||
org.springframework.integration.support.management.MessageChannelMetrics channelMetrics = getChannelMetrics(name);
|
||||
return channelMetrics != null ? channelMetrics.getSendErrorCountLong() : -1;
|
||||
}
|
||||
|
||||
@@ -727,7 +739,8 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
}
|
||||
|
||||
public long getChannelReceiveCountLong(String name) {
|
||||
MessageChannelMetrics channelMetrics = getChannelMetrics(name);
|
||||
org.springframework.integration.support.management.MessageChannelMetrics channelMetrics =
|
||||
getChannelMetrics(name);
|
||||
if (channelMetrics instanceof PollableChannelManagement) {
|
||||
return ((PollableChannelManagement) channelMetrics).getReceiveCountLong();
|
||||
}
|
||||
@@ -735,13 +748,15 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
}
|
||||
|
||||
@ManagedOperation
|
||||
public Statistics getChannelSendRate(String name) {
|
||||
MessageChannelMetrics channelMetrics = getChannelMetrics(name);
|
||||
public org.springframework.integration.support.management.Statistics getChannelSendRate(String name) {
|
||||
org.springframework.integration.support.management.MessageChannelMetrics channelMetrics =
|
||||
getChannelMetrics(name);
|
||||
return channelMetrics != null ? channelMetrics.getSendRate() : null;
|
||||
}
|
||||
|
||||
public Statistics getChannelErrorRate(String name) {
|
||||
MessageChannelMetrics channelMetrics = getChannelMetrics(name);
|
||||
public org.springframework.integration.support.management.Statistics getChannelErrorRate(String name) {
|
||||
org.springframework.integration.support.management.MessageChannelMetrics channelMetrics =
|
||||
getChannelMetrics(name);
|
||||
return channelMetrics != null ? channelMetrics.getErrorRate() : null;
|
||||
}
|
||||
|
||||
@@ -749,7 +764,7 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
this.channels.forEach(this::registerChannel);
|
||||
}
|
||||
|
||||
private void registerChannel(MessageChannelMetrics monitor) {
|
||||
private void registerChannel(org.springframework.integration.support.management.MessageChannelMetrics monitor) {
|
||||
String name = ((NamedComponent) monitor).getComponentName();
|
||||
this.allChannelsByName.put(name, monitor);
|
||||
if (matches(this.componentNamePatterns, name)) {
|
||||
@@ -767,8 +782,8 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
|
||||
}
|
||||
|
||||
private void registerHandler(MessageHandlerMetrics handler) {
|
||||
MessageHandlerMetrics monitor = enhanceHandlerMonitor(handler);
|
||||
private void registerHandler(org.springframework.integration.support.management.MessageHandlerMetrics handler) {
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics monitor = enhanceHandlerMonitor(handler);
|
||||
String name = monitor.getManagedName();
|
||||
if (!this.objectNames.containsKey(handler) && matches(this.componentNamePatterns, name)) {
|
||||
String beanKey = getHandlerBeanKey(monitor);
|
||||
@@ -784,8 +799,8 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
this.sources.forEach(this::registerSource);
|
||||
}
|
||||
|
||||
private void registerSource(MessageSourceMetrics source) {
|
||||
MessageSourceMetrics monitor = enhanceSourceMonitor(source);
|
||||
private void registerSource(org.springframework.integration.support.management.MessageSourceMetrics source) {
|
||||
org.springframework.integration.support.management.MessageSourceMetrics monitor = enhanceSourceMonitor(source);
|
||||
String name = monitor.getManagedName();
|
||||
this.allSourcesByName.put(name, monitor);
|
||||
if (!this.objectNames.containsKey(source) && matches(this.componentNamePatterns, name)) {
|
||||
@@ -873,13 +888,13 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
quoteIfNecessary(channel), extra);
|
||||
}
|
||||
|
||||
private String getHandlerBeanKey(MessageHandlerMetrics handler) {
|
||||
private String getHandlerBeanKey(org.springframework.integration.support.management.MessageHandlerMetrics handler) {
|
||||
// This ordering of keys seems to work with default settings of JConsole
|
||||
return String.format(this.domain + ":type=MessageHandler,name=%s,bean=%s" + getStaticNames(),
|
||||
quoteIfNecessary(handler.getManagedName()), quoteIfNecessary(handler.getManagedType()));
|
||||
}
|
||||
|
||||
private String getSourceBeanKey(MessageSourceMetrics source) {
|
||||
private String getSourceBeanKey(org.springframework.integration.support.management.MessageSourceMetrics source) {
|
||||
// This ordering of keys seems to work with default settings of JConsole
|
||||
return String.format(this.domain + ":type=MessageSource,name=%s,bean=%s" + getStaticNames(),
|
||||
quoteIfNecessary(source.getManagedName()), quoteIfNecessary(source.getManagedType()));
|
||||
@@ -915,7 +930,10 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
private MessageHandlerMetrics enhanceHandlerMonitor(MessageHandlerMetrics monitor) {
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
private org.springframework.integration.support.management.MessageHandlerMetrics enhanceHandlerMonitor(
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics monitor) {
|
||||
|
||||
if (monitor.getManagedName() != null && monitor.getManagedType() != null) {
|
||||
return monitor;
|
||||
}
|
||||
@@ -945,17 +963,19 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
}
|
||||
}
|
||||
|
||||
MessageHandlerMetrics messageHandlerMetrics = buildMessageHandlerMetrics(monitor, name, source, endpoint);
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics messageHandlerMetrics =
|
||||
buildMessageHandlerMetrics(monitor, name, source, endpoint);
|
||||
if (endpointName != null) {
|
||||
this.endpointsByMonitor.put(messageHandlerMetrics, endpointName);
|
||||
}
|
||||
return messageHandlerMetrics;
|
||||
}
|
||||
|
||||
private MessageHandlerMetrics buildMessageHandlerMetrics(MessageHandlerMetrics monitor,
|
||||
private org.springframework.integration.support.management.MessageHandlerMetrics buildMessageHandlerMetrics(
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics monitor,
|
||||
String name, String source, IntegrationConsumer endpoint) {
|
||||
|
||||
MessageHandlerMetrics result = monitor;
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics result = monitor;
|
||||
String managedType = source;
|
||||
String managedName = name;
|
||||
|
||||
@@ -1003,10 +1023,12 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
/**
|
||||
* Wrap the monitor in a lifecycle so it exposes the start/stop operations
|
||||
*/
|
||||
private MessageHandlerMetrics wrapMessageHandlerInLifecycleMetrics(MessageHandlerMetrics monitor,
|
||||
Lifecycle endpoint) {
|
||||
private org.springframework.integration.support.management.MessageHandlerMetrics
|
||||
wrapMessageHandlerInLifecycleMetrics(
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics monitor,
|
||||
Lifecycle endpoint) {
|
||||
|
||||
MessageHandlerMetrics result;
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics result;
|
||||
if (monitor instanceof MappingMessageRouterManagement) {
|
||||
if (monitor instanceof TrackableComponent) {
|
||||
result = new TrackableRouterMetrics(endpoint,
|
||||
@@ -1018,10 +1040,12 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
}
|
||||
else {
|
||||
if (monitor instanceof TrackableComponent) {
|
||||
result = new LifecycleTrackableMessageHandlerMetrics(endpoint, monitor);
|
||||
result = new org.springframework.integration.support.management.
|
||||
LifecycleTrackableMessageHandlerMetrics(endpoint, monitor);
|
||||
}
|
||||
else {
|
||||
result = new LifecycleMessageHandlerMetrics(endpoint, monitor);
|
||||
result = new org.springframework.integration.support.management.
|
||||
LifecycleMessageHandlerMetrics(endpoint, monitor);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -1031,7 +1055,9 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
return name.substring(('_' + SI_PACKAGE).length() + 1);
|
||||
}
|
||||
|
||||
private MessageSourceMetrics enhanceSourceMonitor(MessageSourceMetrics monitor) {
|
||||
private org.springframework.integration.support.management.MessageSourceMetrics enhanceSourceMonitor(
|
||||
org.springframework.integration.support.management.MessageSourceMetrics monitor) {
|
||||
|
||||
if (monitor.getManagedName() != null) {
|
||||
return monitor;
|
||||
}
|
||||
@@ -1048,7 +1074,7 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
source = "internal";
|
||||
}
|
||||
|
||||
MessageSourceMetrics messageSourceMetrics =
|
||||
org.springframework.integration.support.management.MessageSourceMetrics messageSourceMetrics =
|
||||
buildMessageSourceMetricsIfAny(monitor, endpointName, source, endpoint);
|
||||
if (endpointName != null) {
|
||||
this.endpointsByMonitor.put(messageSourceMetrics, endpointName);
|
||||
@@ -1056,7 +1082,10 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
return messageSourceMetrics;
|
||||
}
|
||||
|
||||
private AbstractEndpoint getEndpointForMonitor(MessageSourceMetrics monitor) {
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
private AbstractEndpoint getEndpointForMonitor(
|
||||
org.springframework.integration.support.management.MessageSourceMetrics monitor) {
|
||||
|
||||
for (AbstractEndpoint endpoint : this.applicationContext.getBeansOfType(AbstractEndpoint.class).values()) {
|
||||
Object target = null;
|
||||
if (monitor instanceof MessagingGatewaySupport && endpoint.equals(monitor)) {
|
||||
@@ -1072,10 +1101,11 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
return null;
|
||||
}
|
||||
|
||||
private MessageSourceMetrics buildMessageSourceMetricsIfAny(MessageSourceMetrics monitor, String name,
|
||||
private org.springframework.integration.support.management.MessageSourceMetrics buildMessageSourceMetricsIfAny(
|
||||
org.springframework.integration.support.management.MessageSourceMetrics monitor, String name,
|
||||
String source, Object endpoint) {
|
||||
|
||||
MessageSourceMetrics result = monitor;
|
||||
org.springframework.integration.support.management.MessageSourceMetrics result = monitor;
|
||||
String managedType = source;
|
||||
String managedName = name;
|
||||
|
||||
@@ -1122,8 +1152,10 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
/**
|
||||
* Wrap the monitor in a lifecycle so it exposes the start/stop operations
|
||||
*/
|
||||
private MessageSourceMetrics wrapMessageSourceInLifecycleMetrics(MessageSourceMetrics monitor, Object endpoint) {
|
||||
MessageSourceMetrics result;
|
||||
private org.springframework.integration.support.management.MessageSourceMetrics wrapMessageSourceInLifecycleMetrics(
|
||||
org.springframework.integration.support.management.MessageSourceMetrics monitor, Object endpoint) {
|
||||
|
||||
org.springframework.integration.support.management.MessageSourceMetrics result;
|
||||
if (endpoint instanceof TrackableComponent) {
|
||||
if (monitor instanceof MessageSourceManagement) {
|
||||
result = new LifecycleTrackableMessageSourceManagement((Lifecycle) endpoint,
|
||||
@@ -1139,7 +1171,8 @@ public class IntegrationMBeanExporter extends MBeanExporter
|
||||
(MessageSourceManagement) monitor);
|
||||
}
|
||||
else {
|
||||
result = new LifecycleMessageSourceMetrics((Lifecycle) endpoint, monitor);
|
||||
result = new org.springframework.integration.support.management.LifecycleMessageSourceMetrics(
|
||||
(Lifecycle) endpoint, monitor);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -18,14 +18,15 @@ package org.springframework.integration.monitor;
|
||||
|
||||
import javax.management.Descriptor;
|
||||
|
||||
import org.springframework.integration.support.management.LifecycleMessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.LifecycleMessageSourceMetrics;
|
||||
import org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler;
|
||||
import org.springframework.jmx.export.metadata.JmxAttributeSource;
|
||||
|
||||
/**
|
||||
* The {@link MetadataMBeanInfoAssembler} extension to assemble metadata MBean info
|
||||
* from the {@link LifecycleMessageSourceMetrics} or {@link LifecycleMessageHandlerMetrics}
|
||||
* The {@link MetadataMBeanInfoAssembler} extension to assemble metadata MBean info from
|
||||
* the
|
||||
* {@link org.springframework.integration.support.management.LifecycleMessageSourceMetrics}
|
||||
* or
|
||||
* {@link org.springframework.integration.support.management.LifecycleMessageHandlerMetrics}
|
||||
* managed bean's delegate.
|
||||
* <p>
|
||||
* All other managed beans are left as is.
|
||||
@@ -51,12 +52,15 @@ public class IntegrationMetadataMBeanInfoAssembler extends MetadataMBeanInfoAsse
|
||||
super.populateMBeanDescriptor(desc, extractManagedBean(managedBean), beanKey);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private Object extractManagedBean(Object managedBean) {
|
||||
if (managedBean instanceof LifecycleMessageSourceMetrics) {
|
||||
return ((LifecycleMessageSourceMetrics) managedBean).getDelegate();
|
||||
if (managedBean instanceof org.springframework.integration.support.management.LifecycleMessageSourceMetrics) {
|
||||
return ((org.springframework.integration.support.management.LifecycleMessageSourceMetrics) managedBean)
|
||||
.getDelegate();
|
||||
}
|
||||
else if (managedBean instanceof LifecycleMessageHandlerMetrics) {
|
||||
return ((LifecycleMessageHandlerMetrics) managedBean).getDelegate();
|
||||
else if (managedBean instanceof org.springframework.integration.support.management.LifecycleMessageHandlerMetrics) {
|
||||
return ((org.springframework.integration.support.management.LifecycleMessageHandlerMetrics) managedBean)
|
||||
.getDelegate();
|
||||
}
|
||||
return managedBean;
|
||||
}
|
||||
|
||||
@@ -19,14 +19,15 @@ package org.springframework.integration.monitor;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.springframework.integration.support.management.LifecycleMessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.LifecycleMessageSourceMetrics;
|
||||
import org.springframework.jmx.export.metadata.JmxAttributeSource;
|
||||
import org.springframework.jmx.export.naming.MetadataNamingStrategy;
|
||||
|
||||
/**
|
||||
* The {@link MetadataNamingStrategy} naming extension to extract an {@link ObjectName}
|
||||
* from the {@link LifecycleMessageSourceMetrics} or {@link LifecycleMessageHandlerMetrics}
|
||||
* from the
|
||||
* {@link org.springframework.integration.support.management.LifecycleMessageSourceMetrics}
|
||||
* or
|
||||
* {@link org.springframework.integration.support.management.LifecycleMessageHandlerMetrics}
|
||||
* managed bean's delegate.
|
||||
* <p>
|
||||
* Otherwise delegate to the {@link MetadataNamingStrategy#getObjectName} as is.
|
||||
@@ -47,12 +48,15 @@ public class IntegrationMetadataNamingStrategy extends MetadataNamingStrategy {
|
||||
return super.getObjectName(extractManagedBean(managedBean), beanKey);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private Object extractManagedBean(Object managedBean) {
|
||||
if (managedBean instanceof LifecycleMessageSourceMetrics) {
|
||||
return ((LifecycleMessageSourceMetrics) managedBean).getDelegate();
|
||||
if (managedBean instanceof org.springframework.integration.support.management.LifecycleMessageSourceMetrics) {
|
||||
return ((org.springframework.integration.support.management.LifecycleMessageSourceMetrics) managedBean)
|
||||
.getDelegate();
|
||||
}
|
||||
else if (managedBean instanceof LifecycleMessageHandlerMetrics) {
|
||||
return ((LifecycleMessageHandlerMetrics) managedBean).getDelegate();
|
||||
else if (managedBean instanceof org.springframework.integration.support.management.LifecycleMessageHandlerMetrics) {
|
||||
return ((org.springframework.integration.support.management.LifecycleMessageHandlerMetrics) managedBean)
|
||||
.getDelegate();
|
||||
}
|
||||
return managedBean;
|
||||
}
|
||||
|
||||
@@ -34,12 +34,6 @@ import org.springframework.integration.support.management.AbstractMessageChannel
|
||||
import org.springframework.integration.support.management.AbstractMessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.DefaultMessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.DefaultMessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.ExponentialMovingAverage;
|
||||
import org.springframework.integration.support.management.ExponentialMovingAverageRate;
|
||||
import org.springframework.integration.support.management.ExponentialMovingAverageRatio;
|
||||
import org.springframework.integration.support.management.MessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.MessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.MetricsFactory;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -56,6 +50,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MBeanExporterParserTests {
|
||||
|
||||
@Autowired
|
||||
@@ -72,38 +67,42 @@ public class MBeanExporterParserTests {
|
||||
assertThat(properties.containsKey("bar")).isTrue();
|
||||
assertThat(exporter.getServer()).isEqualTo(server);
|
||||
assertThat(TestUtils.getPropertyValue(exporter, "namingStrategy")).isSameAs(context.getBean("keyNamer"));
|
||||
MessageChannelMetrics metrics = context.getBean("foo", MessageChannelMetrics.class);
|
||||
org.springframework.integration.support.management.MessageChannelMetrics metrics =
|
||||
context.getBean("foo", org.springframework.integration.support.management.MessageChannelMetrics.class);
|
||||
assertThat(metrics.isCountsEnabled()).isTrue();
|
||||
assertThat(metrics.isStatsEnabled()).isFalse();
|
||||
checkCustomized(metrics);
|
||||
MessageHandlerMetrics handlerMetrics = context.getBean("transformer.handler", MessageHandlerMetrics.class);
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics handlerMetrics =
|
||||
context.getBean("transformer.handler",
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics.class);
|
||||
checkCustomized(handlerMetrics);
|
||||
metrics = context.getBean("bar", MessageChannelMetrics.class);
|
||||
metrics = context.getBean("bar", org.springframework.integration.support.management.MessageChannelMetrics.class);
|
||||
assertThat(metrics.isCountsEnabled()).isTrue();
|
||||
assertThat(metrics.isStatsEnabled()).isFalse();
|
||||
metrics = context.getBean("baz", MessageChannelMetrics.class);
|
||||
metrics = context.getBean("baz", org.springframework.integration.support.management.MessageChannelMetrics.class);
|
||||
assertThat(metrics.isCountsEnabled()).isFalse();
|
||||
assertThat(metrics.isStatsEnabled()).isFalse();
|
||||
metrics = context.getBean("qux", MessageChannelMetrics.class);
|
||||
metrics = context.getBean("qux", org.springframework.integration.support.management.MessageChannelMetrics.class);
|
||||
assertThat(metrics.isCountsEnabled()).isFalse();
|
||||
assertThat(metrics.isStatsEnabled()).isFalse();
|
||||
metrics = context.getBean("fiz", MessageChannelMetrics.class);
|
||||
metrics = context.getBean("fiz", org.springframework.integration.support.management.MessageChannelMetrics.class);
|
||||
assertThat(metrics.isCountsEnabled()).isTrue();
|
||||
assertThat(metrics.isStatsEnabled()).isTrue();
|
||||
metrics = context.getBean("buz", MessageChannelMetrics.class);
|
||||
metrics = context.getBean("buz", org.springframework.integration.support.management.MessageChannelMetrics.class);
|
||||
assertThat(metrics.isCountsEnabled()).isTrue();
|
||||
assertThat(metrics.isStatsEnabled()).isTrue();
|
||||
metrics = context.getBean("!excluded", MessageChannelMetrics.class);
|
||||
metrics = context.getBean("!excluded", org.springframework.integration.support.management.MessageChannelMetrics.class);
|
||||
assertThat(metrics.isCountsEnabled()).isFalse();
|
||||
assertThat(metrics.isStatsEnabled()).isFalse();
|
||||
checkCustomized(metrics);
|
||||
MetricsFactory factory = context.getBean(MetricsFactory.class);
|
||||
org.springframework.integration.support.management.MetricsFactory factory =
|
||||
context.getBean(org.springframework.integration.support.management.MetricsFactory.class);
|
||||
IntegrationManagementConfigurer configurer = context.getBean(IntegrationManagementConfigurer.class);
|
||||
assertThat(TestUtils.getPropertyValue(configurer, "metricsFactory")).isSameAs(factory);
|
||||
exporter.destroy();
|
||||
}
|
||||
|
||||
private void checkCustomized(MessageChannelMetrics metrics) {
|
||||
private void checkCustomized(org.springframework.integration.support.management.MessageChannelMetrics metrics) {
|
||||
assertThat(metrics.isLoggingEnabled()).isFalse();
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendDuration.window")).isEqualTo(20);
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "channelMetrics.sendDuration.factor", Double.class))
|
||||
@@ -125,26 +124,30 @@ public class MBeanExporterParserTests {
|
||||
.isCloseTo(.001 / 140000, Offset.offset(.01));
|
||||
}
|
||||
|
||||
private void checkCustomized(MessageHandlerMetrics metrics) {
|
||||
private void checkCustomized(org.springframework.integration.support.management.MessageHandlerMetrics metrics) {
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "handlerMetrics.duration.window")).isEqualTo(20);
|
||||
assertThat(TestUtils.getPropertyValue(metrics, "handlerMetrics.duration.factor", Double.class))
|
||||
.isCloseTo(1000000., Offset.offset(.01));
|
||||
}
|
||||
|
||||
public static class CustomMetrics implements MetricsFactory {
|
||||
public static class CustomMetrics implements org.springframework.integration.support.management.MetricsFactory {
|
||||
|
||||
@Override
|
||||
public AbstractMessageChannelMetrics createChannelMetrics(String name) {
|
||||
return new DefaultMessageChannelMetrics(name,
|
||||
new ExponentialMovingAverage(20, 1000000.),
|
||||
new ExponentialMovingAverageRate(2000, 120000, 30, true),
|
||||
new ExponentialMovingAverageRatio(130000, 40, true),
|
||||
new ExponentialMovingAverageRate(3000, 140000, 50, true));
|
||||
new org.springframework.integration.support.management.ExponentialMovingAverage(20, 1000000.),
|
||||
new org.springframework.integration.support.management.ExponentialMovingAverageRate(2000, 120000,
|
||||
30, true),
|
||||
new org.springframework.integration.support.management.ExponentialMovingAverageRatio(130000, 40,
|
||||
true),
|
||||
new org.springframework.integration.support.management.ExponentialMovingAverageRate(3000, 140000,
|
||||
50, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractMessageHandlerMetrics createHandlerMetrics(String name) {
|
||||
return new DefaultMessageHandlerMetrics(name, new ExponentialMovingAverage(20, 1000000.));
|
||||
return new DefaultMessageHandlerMetrics(name,
|
||||
new org.springframework.integration.support.management.ExponentialMovingAverage(20, 1000000.));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,8 +40,6 @@ import org.springframework.integration.config.EnableIntegrationManagement;
|
||||
import org.springframework.integration.config.IntegrationManagementConfigurer;
|
||||
import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
|
||||
import org.springframework.integration.monitor.IntegrationMBeanExporter;
|
||||
import org.springframework.integration.support.management.DefaultMetricsFactory;
|
||||
import org.springframework.integration.support.management.MetricsFactory;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.jmx.support.MBeanServerFactoryBean;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
@@ -71,8 +69,9 @@ public class EnableMBeanExportTests {
|
||||
@Autowired
|
||||
private IntegrationManagementConfigurer configurer;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Autowired
|
||||
private MetricsFactory myMetricsFactory;
|
||||
private org.springframework.integration.support.management.MetricsFactory myMetricsFactory;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
@@ -142,9 +141,10 @@ public class EnableMBeanExportTests {
|
||||
return new QueueChannel();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Bean
|
||||
public MetricsFactory myMetricsFactory() {
|
||||
return new DefaultMetricsFactory();
|
||||
public org.springframework.integration.support.management.MetricsFactory myMetricsFactory() {
|
||||
return new org.springframework.integration.support.management.DefaultMetricsFactory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.support.management.MessageHandlerMetrics;
|
||||
import org.springframework.integration.support.management.BaseHandlerMetrics;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
@@ -54,6 +54,7 @@ public class ChannelIntegrationTests {
|
||||
@Autowired
|
||||
private IntegrationMBeanExporter messageChannelsMonitor;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testMessageChannelStatistics() throws Exception {
|
||||
|
||||
@@ -76,7 +77,7 @@ public class ChannelIntegrationTests {
|
||||
try {
|
||||
requests.send(new GenericMessage<String>("foo"));
|
||||
}
|
||||
catch (MessageDeliveryException e) {
|
||||
catch (@SuppressWarnings("unused") MessageDeliveryException e) {
|
||||
}
|
||||
|
||||
assertThat(messageChannelsMonitor.getChannelSendCount(intermediateChannelName)).isEqualTo(3);
|
||||
@@ -85,10 +86,11 @@ public class ChannelIntegrationTests {
|
||||
|
||||
assertThat(messageChannelsMonitor.getChannelMetrics(intermediateChannelName)).isSameAs(intermediate);
|
||||
|
||||
MessageHandlerMetrics handlerMetrics = messageChannelsMonitor.getHandlerMetrics("bridge");
|
||||
BaseHandlerMetrics handlerMetrics = messageChannelsMonitor
|
||||
.getHandlerMetrics("bridge");
|
||||
|
||||
assertThat(handlerMetrics.getHandleCount()).isEqualTo(3);
|
||||
assertThat(handlerMetrics.getErrorCount()).isEqualTo(1);
|
||||
assertThat(handlerMetrics.handleCount()).isEqualTo(3);
|
||||
assertThat(handlerMetrics.errorCount()).isEqualTo(1);
|
||||
|
||||
assertThat(this.sourceChannel.receive(10000)).isNotNull();
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.endpoint.AbstractMessageSource;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.support.management.DefaultMessageChannelMetrics;
|
||||
import org.springframework.integration.support.management.MetricsContext;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
@@ -75,6 +74,7 @@ public class MonitorTests {
|
||||
private NullChannel nullChannel;
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testStats() throws InterruptedException {
|
||||
final CountDownLatch afterSendLatch = new CountDownLatch(1);
|
||||
@@ -87,7 +87,9 @@ public class MonitorTests {
|
||||
Object result = invocation.callRealMethod();
|
||||
afterSendLatch.countDown();
|
||||
return result;
|
||||
}).when(channelMetrics).afterSend(Mockito.any(MetricsContext.class), Mockito.eq(Boolean.TRUE));
|
||||
}).when(channelMetrics)
|
||||
.afterSend(Mockito.any(org.springframework.integration.support.management.MetricsContext.class),
|
||||
Mockito.eq(Boolean.TRUE));
|
||||
|
||||
new DirectFieldAccessor(this.next).setPropertyValue("channelMetrics", channelMetrics);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
|
||||
public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMessageGroupStore
|
||||
implements BasicMessageGroupStore, InitializingBean, ApplicationContextAware {
|
||||
implements InitializingBean, ApplicationContextAware {
|
||||
|
||||
public static final String SEQUENCE_NAME = "messagesSequence";
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ Starting with version 5.0.2, the framework automatically detects whether the app
|
||||
[[micrometer-integration]]
|
||||
==== Micrometer Integration
|
||||
|
||||
Starting with version 5.0.3, the presence of a https://micrometer.io/[Micrometer] `MeterRegistry` in the application context triggers support for Micrometer metrics in addition to the built-in metrics (note that built-in metrics will be removed in a future release).
|
||||
Starting with version 5.0.3, the presence of a https://micrometer.io/[Micrometer] `MeterRegistry` in the application context triggers support for Micrometer metrics in addition to the built-in metrics (note that the legacy built-in metrics will be removed in a future release).
|
||||
|
||||
IMPORTANT: Micrometer was first supported in version 5.0.2, but changes were made to the Micrometer `Meters` in version 5.0.3 to make them more suitable for use in dimensional systems.
|
||||
Further changes were made in 5.0.4.
|
||||
|
||||
Reference in New Issue
Block a user