Skip to content

Monitor: Refactor transaction handling and control flow in monitoring services #265

Description

@katharinabassler

The current implementation mixes state evaluation, persistence, and transaction management across multiple classes (MicroService, MonitorServices, DockerService), which has lead to both errors being ignored silently and service states being reported incorrectly. Additionally, a complex control flow complicates debugging.

Proposals:

  1. Separate concerns: determine state first (regardless of chosen method), call persisting method afterwards and only once
  2. Centralize transaction handling: reuse RestTemplate via injection, optionally use @Retryable to simplify retry logic (e.g. @Retryable(value = CannotAcquireLockException.class, maxAttempts = 3)), avoid creating transactions in helper methods such as getMonService() which has lead to broken transactions in the past, or implement proper transaction propagation
  3. Simplify control flow: split check scenarios into smaller methods with proper log messages to simplify debugging
  4. Guard against empty optionals (MicroService)
  5. Optionally, replace Thread with Spring's @Scheduled: managed by Spring container, automatic lifecycle, built-in scheduling options, cleaner code

Activity

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

Metadata

Metadata

Labels

backlog(To be) Covered by the prosEO Backlog

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions