Skip to content

Commit 3d87ac6

Browse files
artembilangaryrussell
authored andcommitted
Polishing pollable channels around meters
1 parent 7efb14c commit 3d87ac6

File tree

3 files changed

+13
-31
lines changed

3 files changed

+13
-31
lines changed

spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/PollableAmqpChannel.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,4 @@ public boolean hasExecutorInterceptors() {
364364
return this.executorInterceptorsSize > 0;
365365
}
366366

367-
@Override
368-
public void destroy() {
369-
super.destroy();
370-
if (this.receiveCounter != null) {
371-
this.receiveCounter.remove();
372-
}
373-
}
374-
375367
}

spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractPollableChannel.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
public abstract class AbstractPollableChannel extends AbstractMessageChannel
4141
implements PollableChannel, PollableChannelManagement, ExecutorChannelInterceptorAware {
4242

43-
private volatile int executorInterceptorsSize;
43+
private int executorInterceptorsSize;
4444

4545
private CounterFacade receiveCounter;
4646

@@ -67,7 +67,6 @@ public long getReceiveErrorCountLong() {
6767
/**
6868
* Receive the first available message from this channel. If the channel
6969
* contains no messages, this method will block.
70-
*
7170
* @return the first available message or <code>null</code> if the
7271
* receiving thread is interrupted.
7372
*/
@@ -83,9 +82,7 @@ public Message<?> receive() {
8382
* elapses. If the specified timeout is 0, the method will return
8483
* immediately. If less than zero, it will block indefinitely (see
8584
* {@link #receive()}).
86-
*
8785
* @param timeout the timeout in milliseconds
88-
*
8986
* @return the first available message or <code>null</code> if no message
9087
* is available within the allotted time or the receiving thread is
9188
* interrupted.
@@ -97,8 +94,9 @@ public Message<?> receive(long timeout) {
9794
Deque<ChannelInterceptor> interceptorStack = null;
9895
boolean counted = false;
9996
boolean countsEnabled = isCountsEnabled();
97+
boolean traceEnabled = isLoggingEnabled() && logger.isTraceEnabled();
10098
try {
101-
if (isLoggingEnabled() && logger.isTraceEnabled()) {
99+
if (traceEnabled) {
102100
logger.trace("preReceive on channel '" + this + "'");
103101
}
104102
if (interceptorList.getSize() > 0) {
@@ -110,7 +108,7 @@ public Message<?> receive(long timeout) {
110108
}
111109
Message<?> message = doReceive(timeout);
112110
if (message == null) {
113-
if (isLoggingEnabled() && logger.isTraceEnabled()) {
111+
if (traceEnabled) {
114112
logger.trace("postReceive on channel '" + this + "', message is null");
115113
}
116114
}
@@ -121,10 +119,9 @@ public Message<?> receive(long timeout) {
121119
counted = true;
122120
}
123121

124-
if (isLoggingEnabled() && logger.isDebugEnabled()) {
122+
if (traceEnabled) {
125123
logger.debug("postReceive on channel '" + this + "', message: " + message);
126124
}
127-
128125
}
129126

130127
if (interceptorStack != null && message != null) {
@@ -235,12 +232,4 @@ public boolean hasExecutorInterceptors() {
235232
@Nullable
236233
protected abstract Message<?> doReceive(long timeout);
237234

238-
@Override
239-
public void destroy() {
240-
super.destroy();
241-
if (this.receiveCounter != null) {
242-
this.receiveCounter.remove();
243-
}
244-
}
245-
246235
}

spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,14 @@ public boolean send(Message<?> message) {
251251

252252
private TimerFacade sendTimer() {
253253
if (this.successTimer == null) {
254-
this.successTimer = this.metricsCaptor.timerBuilder(SEND_TIMER_NAME)
255-
.tag("type", "channel")
256-
.tag("name", getComponentName() == null ? "nullChannel" : getComponentName())
257-
.tag("result", "success")
258-
.tag("exception", "none")
259-
.description("Subflow process time")
260-
.build();
254+
this.successTimer =
255+
this.metricsCaptor.timerBuilder(SEND_TIMER_NAME)
256+
.tag("type", "channel")
257+
.tag("name", getComponentName() == null ? "nullChannel" : getComponentName())
258+
.tag("result", "success")
259+
.tag("exception", "none")
260+
.description("Subflow process time")
261+
.build();
261262
}
262263
return this.successTimer;
263264
}

0 commit comments

Comments
 (0)