This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.14.x by this push:
new c95359c63d0 CAMEL-22410: polling consumers when using
concurrentConsumers > 1 should correctly keep track of how many consumers are
polling using a counter instead of a shared boolean.
c95359c63d0 is described below
commit c95359c63d02d154547ce68ae8359c89b9445f96
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Sep 18 09:47:45 2025 +0200
CAMEL-22410: polling consumers when using concurrentConsumers > 1 should
correctly keep track of how many consumers are polling using a counter instead
of a shared boolean.
---
.../main/java/org/apache/camel/support/ScheduledPollConsumer.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git
a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java
b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java
index ae99f7392f8..14a634b5a44 100644
---
a/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java
+++
b/core/camel-support/src/main/java/org/apache/camel/support/ScheduledPollConsumer.java
@@ -72,7 +72,7 @@ public abstract class ScheduledPollConsumer extends
DefaultConsumer
private Map<String, Object> schedulerProperties;
// state during running
- private volatile boolean polling;
+ private final AtomicInteger pollingCounter = new AtomicInteger();
private final AtomicInteger backoffCounter = new AtomicInteger();
private final AtomicLong idleCounter = new AtomicLong();
private final AtomicLong errorCounter = new AtomicLong();
@@ -200,7 +200,7 @@ public abstract class ScheduledPollConsumer extends
DefaultConsumer
}
// mark we are polling which should also include the
begin/poll/commit
- polling = true;
+ pollingCounter.incrementAndGet();
try {
boolean begin = pollStrategy.begin(this,
getEndpoint());
if (begin) {
@@ -233,7 +233,7 @@ public abstract class ScheduledPollConsumer extends
DefaultConsumer
LOG.debug("Cannot begin polling as pollStrategy
returned false: {}", pollStrategy);
}
} finally {
- polling = false;
+ pollingCounter.decrementAndGet();
}
}
@@ -322,7 +322,7 @@ public abstract class ScheduledPollConsumer extends
DefaultConsumer
* Whether polling is currently in progress
*/
public boolean isPolling() {
- return polling;
+ return pollingCounter.get() > 0;
}
public ScheduledPollConsumerScheduler getScheduler() {