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

Only control retry policy template lifecycle if the source is its act… #14249

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 @@ -188,6 +188,7 @@ public class ExtensionMessageSource extends ExtensionComponent<SourceModel> impl
private final String applicationName;

private final AtomicBoolean started = new AtomicBoolean(false);
private boolean shouldControlRetryPolicyLifecycle;

public ExtensionMessageSource(ExtensionModel extensionModel,
SourceModel sourceModel,
Expand All @@ -203,6 +204,7 @@ public ExtensionMessageSource(ExtensionModel extensionModel,
this.sourceModel = sourceModel;
this.sourceAdapterFactory = sourceAdapterFactory;
this.customRetryPolicyTemplate = retryPolicyTemplate;
this.shouldControlRetryPolicyLifecycle = retryPolicyTemplate != null;
this.primaryNodeOnly = primaryNodeOnly;
this.backPressureStrategy = backPressureStrategy;
this.notificationDispatcher = notificationDispatcher;
Expand All @@ -226,7 +228,9 @@ private synchronized void createSource(boolean restarting) throws Exception {
restarting);
muleContext.getInjector().inject(sourceAdapter);
retryPolicyTemplate = createRetryPolicyTemplate(customRetryPolicyTemplate);
initialiseIfNeeded(retryPolicyTemplate, true, muleContext);
if (shouldControlRetryPolicyLifecycle) {
initialiseIfNeeded(retryPolicyTemplate, true, muleContext);
}
} finally {
if (initialiserEvent != null) {
((BaseEventContext) initialiserEvent.getContext()).success();
Expand Down Expand Up @@ -486,7 +490,9 @@ private void reallyDoStart() throws MuleException {
LOGGER.debug("Message source '{}' on flow '{}' is starting", sourceModel.getName(),
getLocation().getRootContainerName());
lifecycle(() -> lifecycleManager.fireStartPhase((phase, o) -> {
startIfNeeded(retryPolicyTemplate);
if (shouldControlRetryPolicyLifecycle) {
startIfNeeded(retryPolicyTemplate);
}

if (retryScheduler == null) {
retryScheduler = schedulerService.ioScheduler();
Expand Down Expand Up @@ -519,8 +525,10 @@ public void doDispose() {
try {
safeLifecycle(() -> lifecycleManager.fireDisposePhase((phase, o) -> {
disposeSource();
stopIfNeeded(retryPolicyTemplate);
disposeIfNeeded(retryPolicyTemplate, LOGGER);
if (shouldControlRetryPolicyLifecycle) {
stopIfNeeded(retryPolicyTemplate);
disposeIfNeeded(retryPolicyTemplate, LOGGER);
}
stopSchedulers();
}));
} catch (MuleException e) {
Expand Down