Skip to content

Fix retry task ignoring admin UI disable on restart - #17

Open
mherman22 wants to merge 1 commit into
IsantePlus:masterfrom
mherman22:fix-retry-task-start-on-startup
Open

Fix retry task ignoring admin UI disable on restart#17
mherman22 wants to merge 1 commit into
IsantePlus:masterfrom
mherman22:fix-retry-task-start-on-startup

Conversation

@mherman22

@mherman22 mherman22 commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Problem

The retry task was created with startOnStartup=true which causes OpenMRS to auto-start it on every boot regardless of whether it was disabled via the admin Manage Scheduled Tasks UI.

The previous workaround (commenting out createTaskIfNotExists and calling stopTaskIfExists did not work because OpenMRS reads startOnStartup from the database and starts the task before any module activator runs.

The retry task processes failed PIX/PDQ/XDS messages. On sites where MPI is not configured, these retries produce hundreds of errors per cycle:

ERROR - PixRetryInvoker.retry(72) | Unsuccessful retry
    at org.openmrs.module.outgoingmessageexceptions.api.retry.impl.RetryServiceImpl.retryAll(RetryServiceImpl.java:28)
    at org.openmrs.module.outgoingmessageexceptions.api.retry.impl.RetryTask.execute(RetryTask.java:22)

ERROR - DocumentBuilderImpl.generate(239) | org.marc.everest.exceptions.DuplicateItemException
    at org.openmrs.module.outgoingmessageexceptions.api.retry.impl.XdsBRetryInvoker.retry(XdsBRetryInvoker.java:42)
    at org.openmrs.module.outgoingmessageexceptions.api.retry.impl.RetryServiceImpl.retryAll(RetryServiceImpl.java:33)
    at org.openmrs.module.outgoingmessageexceptions.api.retry.impl.RetryTask.execute(RetryTask.java:22)

Fix

  • Restore createTaskIfNotExists() in the activator, remove the stopTaskIfExists() workaround
  • On each startup, delete any existing task definition and recreate it with startOnStartup=false. This clears any stale flag from the database. The task runs for the current session via scheduleTask() but won't auto-start on next boot.

Changes

  • OutgoingMessageExceptionsActivator.java — restore createTaskIfNotExists(), remove stopTaskIfExists() workaround
  • RetrySchedulerServiceImpl.java — delete existing task before creating fresh with startOnStartup=false

The retry task was created with startOnStartup=true, which causes
OpenMRS to auto-start it on every boot regardless of whether it was
disabled via the admin UI.

Fix:
- Restore createTaskIfNotExists() in the activator
- Remove the stopTaskIfExists() workaround
- On each startup, delete any existing task definition and recreate
  it with startOnStartup=false. This clears any stale startOnStartup
  flag from the database. The task runs for the current session via
  scheduleTask() but won't auto-start on next boot.
@ibacher

ibacher commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

I still think we should stop the task on startup because it’s running in every iSantePlus instance, but let’s also have it set the task to not start on startup as part of that.

Good catch @mherman22!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants