Propagate startup failure properties to created container#1506
Open
seonwooj0810 wants to merge 1 commit into
Open
Propagate startup failure properties to created container#1506seonwooj0810 wants to merge 1 commit into
seonwooj0810 wants to merge 1 commit into
Conversation
ConcurrentPulsarListenerContainerFactory#createContainerInstance builds a fresh PulsarContainerProperties for each container and only copies a curated subset of the factory's container properties onto it. The startup failure policy and startup failure retry template were not among them, so a StartupFailurePolicy.RETRY (and a custom retry template) configured on the factory - for example via a PulsarContainerFactoryCustomizer, which is the documented way to opt into startup retries - was silently dropped and the container kept the default STOP policy. Copy the startup failure retry template and policy from the factory props to the container props. The retry template is set first because setting a non-null template implicitly switches the policy to RETRY; the policy is then set explicitly to mirror the factory exactly. Signed-off-by: seonwoo_jung <79202163+seonwooj0810@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1505
Problem
ConcurrentPulsarListenerContainerFactory#createContainerInstancecreates a freshPulsarContainerPropertiesfor every container and copies only a curated subset of the factory's container properties onto it (consumer task executor, schema/topic resolvers, subscription type/name, transactions). The startup failure policy and startup failure retry template are not among them.As a result, when a user configures
StartupFailurePolicy.RETRYand/or a customstartupFailureRetryTemplateon the factory's container properties — e.g. via aPulsarContainerFactoryCustomizer, which is the documented way to opt into startup retries — those settings are silently dropped and the created container keeps the defaultSTOPpolicy (Configured to stop on startup failures - exiting).Fix
Copy the startup failure retry template and policy from the factory props to the container props in
createContainerInstance. The retry template is set before the policy becausePulsarContainerProperties#setStartupFailureRetryTemplateimplicitly switches the policy toRETRYwhen given a non-null template; the policy is then set explicitly to mirror the factory exactly.Tests
Added unit tests to
ConcurrentPulsarListenerContainerFactoryTests:StartupFailurePolicyFrom— factory's policy is propagated to the created container, and the default (STOP) is used when unset.StartupFailureRetryTemplateFrom— factory's retry template is propagated (and the policy is switched toRETRYaccordingly).Verification done
./gradlew :spring-pulsar:test --tests "*ConcurrentPulsarListenerContainerFactoryTests"— BUILD SUCCESSFUL (new tests pass; compiled with-Werrorand the project's nullability/errorprone checks)../gradlew :spring-pulsar:checkFormat :spring-pulsar:checkstyleMain :spring-pulsar:checkstyleTest— BUILD SUCCESSFUL.formattask surfaced in an unrelated class was reverted).Note: this PR addresses the startup-failure properties called out by the reproducer; if maintainers prefer, the same propagation block could later be reviewed for any other factory-level properties not yet copied.