Skip to content

ProcessOB3PRetention run lifecycle

A run moves through argument resolution, dependency registration, application resolution, the Initialize/Execute/Finish lifecycle, and a framework-controlled exit. The Execute stage holds all of the application's work and is documented in Process third-party retention.

Lifecycle flow

The diagram shows the successful path and three failure exits: argument validation, resolution/construction failure (no application instance exists, so no footer is written), and an Execute failure (the constructed application is disposed and writes the footer).

flowchart TD
    A["Main: new Program().Run()"] --> B["Create ArgContainer"]
    B --> C{"Arguments valid?"}
    C -- "No" --> D["Write invalid argument list to stderr"]
    D --> E["Exit code 1"]
    C -- "Yes" --> F["RegisterAppDependencies"]
    F --> G["Build container, resolve application"]
    G --> H{"Resolution and client construction succeed?"}
    H -- "No: missing or empty URL setting,<br>or invalid URI" --> X1["Runner writes exception to stderr"]
    X1 --> Y1["Exit code 5 (no instance to dispose)"]
    H -- "Yes" --> I["Write start header and user/track"]
    I --> J["Initialize (empty)"]
    J --> K["Execute"]
    K --> L{"Execute threw?"}
    L -- "Yes" --> X["Execute writes Error: to stderr, rethrows"]
    X --> Y["Exit code 5"]
    L -- "No" --> M["Finish (empty)"]
    M --> N["Exit code 0"]
    N --> O["Dispose writes end footer"]
    Y --> O
    E --> P["Echo Exit Code"]
    O --> P
    Y1 --> P

Stages

Stage Behavior
Entry Main calls new Program().Run(). A key press is awaited only when a debugger is attached.†
Argument resolution CreateArgumentContainer then ResolveArguments. On failure the runner writes Invalid arguments list (n total): and the messages to stderr, sets exit code 1, calls Console.ReadLine(), and does not run the application.† Whether Console.ReadLine() blocks an unattended run is not confirmed.**
Registration RegisterAppDependencies configures OpenTelemetry, registers common dependencies, IImagingApiClient, and IOnBaseService.
Resolution The container resolves ThirdPartyRetentionProcessor; the service constructors read imagingapiurl and ProcessOB3PRetention.WSPEndPointUrl.
Header Writes ThirdPartyRetentionProcessor began at <time>. and Running as: <userId> on track: <track>.†
Initialize Empty override; no work.
Execute Performs the retention workflow. Exit code is preset to 0 before Execute runs.†
Finish Empty override; skipped if Execute throws.†
Dispose Runs only when the application instance was constructed (success, or Execute failure): writes the footer (an ended-at line and a ran-for-n-seconds line). If resolution or client construction fails, no instance exists and no footer is written.* Exit Code: n is echoed in every case.†

Exit codes

Code Meaning Trigger
0 Success Run completed, including the case where no claims were eligible
1 Argument validation failure A Day, Month, or Year value is not a valid Int32, or a flag is supplied without a value
5 Unhandled runtime failure Missing or empty configuration, Imaging API errors, or OnBase SOAP errors

The other SaifConsoleException exit codes defined by the framework are never raised by this application, and the application never sets the process exit code itself.

Failure behavior

Execute catches every exception, writes Error: <message> to stderr, and rethrows with throw ex;, which resets the stack trace. The runner then reports the exception again, so the message can appear twice on stderr, and the disposed application writes its footer.† A failure while resolving the application (missing or empty URL setting, invalid URI) occurs inside CreateApplication before any instance exists: the runner reports the exception and sets exit code 5, but no Error: line from Execute, no start header, and no footer are written.* Batches completed before the failure are not rolled back, and remaining batches are not attempted.

Documentation Description
Index Documentation entry point
Overview Purpose and capabilities
Architecture Components and composition root
Arguments Argument contract
Configuration Settings and environment variables
Dependencies Packages and API dependencies
Operations and processes Operation catalog
Business rules Rules enforced during processing
Operational runbook Run and recovery procedures
Tech debt Technical debt observations

Note: Statements marked with † are derived from dependency library documentation via the Legends CLI. Statements marked with * were inferred from code structure or contextual evidence. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • ProcessOB3PRetention/Program.cs
  • ProcessOB3PRetention/ThirdPartyRetentionProcessor.cs
  • ProcessOB3PRetention/ArgContainer.cs
  • ProcessOB3PRetention/Services/ImagingApiClient.cs
  • ProcessOB3PRetention/Services/OnBaseService.cs