Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid fenced Container to stop ConcurrentContainer #3537

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public abstract class AbstractMessageListenerContainer<K, V>

protected final ReentrantLock lifecycleLock = new ReentrantLock(); // NOSONAR

protected final AtomicBoolean enforceRebalanceRequested = new AtomicBoolean();
private final AtomicBoolean enforceRebalanceRequested = new AtomicBoolean();

private final Set<TopicPartition> pauseRequestedPartitions = ConcurrentHashMap.newKeySet();

Expand Down Expand Up @@ -193,6 +193,14 @@ protected AbstractMessageListenerContainer(ConsumerFactory<? super K, ? super V>
}
}

/**
* To be used only with {@link ConcurrentMessageListenerContainerRef}.
*/
AbstractMessageListenerContainer() {
this.containerProperties = null;
this.consumerFactory = null;
}

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
Expand Down Expand Up @@ -278,15 +286,27 @@ public boolean isRunning() {
return this.running;
}

protected void setFenced(boolean fenced) {
void setFenced(boolean fenced) {
this.fenced = fenced;
}

protected boolean isFenced() {
return this.fenced;
}

@Deprecated(since = "3.2", forRemoval = true)
protected boolean isPaused() {
return this.paused;
}

protected boolean isEnforceRebalanceRequested() {
return this.enforceRebalanceRequested.get();
}

protected void setEnforceRebalanceRequested(boolean enforceRebalance) {
this.enforceRebalanceRequested.set(enforceRebalance);
}

@Override
public boolean isPartitionPauseRequested(TopicPartition topicPartition) {
return this.pauseRequestedPartitions.contains(topicPartition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,17 @@ private KafkaMessageListenerContainer<K, V> constructContainer(ContainerProperti
@Nullable TopicPartitionOffset[] topicPartitions, int i) {

KafkaMessageListenerContainer<K, V> container;
ConcurrentMessageListenerContainerRef concurrentMessageListenerContainerRef =
new ConcurrentMessageListenerContainerRef<>(this, this.lifecycleLock);
if (topicPartitions == null) {
container = new KafkaMessageListenerContainer<>(this, this.consumerFactory, containerProperties); // NOSONAR
container = new KafkaMessageListenerContainer<>(concurrentMessageListenerContainerRef, this,
this.consumerFactory, containerProperties); // NOSONAR
}
else {
container = new KafkaMessageListenerContainer<>(this, this.consumerFactory, // NOSONAR
containerProperties, partitionSubset(containerProperties, i));
container = new KafkaMessageListenerContainer<>(concurrentMessageListenerContainerRef, this,
this.consumerFactory, containerProperties, partitionSubset(containerProperties, i)); // NOSONAR
}
concurrentMessageListenerContainerRef.setKafkaMessageListenerContainer(container);
return container;
}

Expand Down
Loading
Loading