Remove Legacy Metrics

- Simplify MBeans - instead of wrapping to expose lifecycle methods,
  implement `ManageableLifecycle`. Register an additional MBean for
  polled endpoints to control the lifecycle.

* Polishing

- Move `QueueChannel` `@ManagedAttribute`s to `QueueChannelOperations`
- Make all `AbstractEndpoints` `IntegrationManagedResource`s and remove `ManagedEndpoint`
  to allow exposure of any `@Managed*` methods (including those on `Pausable`)
- Revert to `Lifecycle` for classes that are not related to endpoints
- Remove legacy metrics from docs
This commit is contained in:
Gary Russell
2020-08-07 12:56:57 -04:00
committed by GitHub
parent da5d002d64
commit 1beb854fb4
148 changed files with 533 additions and 7064 deletions

View File

@@ -45,7 +45,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.Lifecycle;
import org.springframework.core.convert.ConversionService;
import org.springframework.expression.Expression;
import org.springframework.integration.MessageTimeoutException;
@@ -54,6 +53,7 @@ import org.springframework.integration.handler.AbstractReplyProducingMessageHand
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
import org.springframework.integration.jms.util.JmsAdapterUtils;
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
import org.springframework.integration.support.management.ManageableLifecycle;
import org.springframework.integration.util.JavaUtils;
import org.springframework.jms.connection.ConnectionFactoryUtils;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
@@ -82,7 +82,8 @@ import org.springframework.util.concurrent.SettableListenableFuture;
* @author Gary Russell
* @author Artem Bilan
*/
public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler implements Lifecycle, MessageListener {
public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler
implements ManageableLifecycle, MessageListener {
/**
* A default receive timeout in milliseconds.

View File

@@ -38,10 +38,8 @@ import org.springframework.messaging.support.ExecutorChannelInterceptor;
*
* @since 2.0
*/
@SuppressWarnings("deprecation")
public class PollableJmsChannel extends AbstractJmsChannel
implements PollableChannel, org.springframework.integration.support.management.PollableChannelManagement,
ExecutorChannelInterceptorAware {
implements PollableChannel, ExecutorChannelInterceptorAware {
private String messageSelector;
@@ -57,50 +55,6 @@ public class PollableJmsChannel extends AbstractJmsChannel
this.messageSelector = messageSelector;
}
/**
* Deprecated.
* @return receive count
* @deprecated in favor of Micrometer metrics.
*/
@Deprecated
@Override
public int getReceiveCount() {
return getMetrics().getReceiveCount();
}
/**
* Deprecated.
* @return receive count
* @deprecated in favor of Micrometer metrics.
*/
@Deprecated
@Override
public long getReceiveCountLong() {
return getMetrics().getReceiveCountLong();
}
/**
* Deprecated.
* @return receive error count
* @deprecated in favor of Micrometer metrics.
*/
@Deprecated
@Override
public int getReceiveErrorCount() {
return getMetrics().getReceiveErrorCount();
}
/**
* Deprecated.
* @return receive error count
* @deprecated in favor of Micrometer metrics.
*/
@Deprecated
@Override
public long getReceiveErrorCountLong() {
return getMetrics().getReceiveErrorCountLong();
}
@Override
@Nullable
public Message<?> receive(long timeout) {
@@ -119,7 +73,6 @@ public class PollableJmsChannel extends AbstractJmsChannel
ChannelInterceptorList interceptorList = getIChannelInterceptorList();
Deque<ChannelInterceptor> interceptorStack = null;
boolean counted = false;
boolean countsEnabled = isCountsEnabled();
try {
if (isLoggingEnabled() && logger.isTraceEnabled()) {
logger.trace("preReceive on channel '" + this + "'");
@@ -146,11 +99,8 @@ public class PollableJmsChannel extends AbstractJmsChannel
}
}
else {
if (countsEnabled) {
incrementReceiveCounter();
getMetrics().afterReceive();
counted = true;
}
incrementReceiveCounter();
counted = true;
if (object instanceof Message<?>) {
message = (Message<?>) object;
}
@@ -170,7 +120,7 @@ public class PollableJmsChannel extends AbstractJmsChannel
return message;
}
catch (RuntimeException ex) {
if (countsEnabled && !counted) {
if (!counted) {
incrementReceiveErrorCounter(ex);
}
interceptorList.afterReceiveCompletion(null, this, ex, interceptorStack);
@@ -193,7 +143,6 @@ public class PollableJmsChannel extends AbstractJmsChannel
if (metricsCaptor != null) {
buildReceiveCounter(metricsCaptor, ex).increment();
}
getMetrics().afterError();
}
private CounterFacade buildReceiveCounter(MetricsCaptor metricsCaptor, @Nullable Exception ex) {

View File

@@ -21,7 +21,6 @@ import javax.jms.MessageListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.SmartLifecycle;
import org.springframework.integration.MessageDispatchingException;
import org.springframework.integration.channel.BroadcastCapableChannel;
import org.springframework.integration.context.IntegrationProperties;
@@ -31,6 +30,7 @@ import org.springframework.integration.dispatcher.MessageDispatcher;
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
import org.springframework.integration.dispatcher.UnicastingDispatcher;
import org.springframework.integration.support.MessageBuilderFactory;
import org.springframework.integration.support.management.ManageableSmartLifecycle;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.listener.AbstractMessageListenerContainer;
import org.springframework.jms.support.converter.MessageConverter;
@@ -52,7 +52,7 @@ import org.springframework.util.Assert;
* @since 2.0
*/
public class SubscribableJmsChannel extends AbstractJmsChannel
implements BroadcastCapableChannel, SmartLifecycle {
implements BroadcastCapableChannel, ManageableSmartLifecycle {
private final AbstractMessageListenerContainer container;