Lattice Async Operation Processing
What it does. Runs the asynchronous service operations that are still waiting to run, and settles the ones whose processing stopped without a result. Runs: automatically every minute as a background process. Who looks after it: Integration administrator (which operations may run asynchronously, and running one now); System administrator (the background process itself, on a standard page).
Purpose
A caller that submits a long posting with submitAsyncOperation gets a tracking ID back at once, and the work runs
later on the batch server. Each submission schedules its own one-time batch job, so most operations start within
seconds. This background process is the safety net behind those jobs:
- It runs every operation that is still Queued: one whose own batch job did not run, one whose batch job ran while the Lattice license blocked processing, and one that the recovery below queued again.
- It finds operations that have been Processing for more than 60 minutes (the server or the batch task stopped after the operation started) and settles each one, without ever running again an operation that may already have posted.
Without it, an operation whose own batch job did not run stays Queued, and a caller polling
getAsyncOperationStatus never sees it finish. An operation interrupted while it ran stays Processing until the
Lattice dead-letter retry process happens to run, which does the same recovery but does not
run the operations it queues again.
When it runs
- Every minute. It is one process for the whole environment, not one per legal entity.
- The database synchronization of a Lattice deployment registers it, and process automation must be initialized in the environment. There is no batch job for you to create.
- Each poll first runs the recovery of interrupted operations, then lists the Queued operations. When none is queued, no batch job is created.
- While the license blocks Lattice processing, the poll still runs the recovery but starts no operation. The queued operations wait and run at the first poll after the license is restored.
Configuration and scheduling
| Setting | Where | Default |
|---|---|---|
| How often it runs | System administration > Setup > Process automations, Background processes tab: select Lattice Async Operation Processing and choose Edit, then Repeat interval on the Execution parameters tab | Every minute |
| A time of day when it does not run | The same dialog, Sleep time period group (Enabled sleep period, Sleep from, Sleep to) | Not set by Lattice |
| The user it runs as | The same dialog, owner field on the Background process tab | The user the deployment's database synchronization ran as |
| Which operations may run asynchronously | System administration > Setup > Lattice > Async operation registry, Enabled | Every shipped operation enabled |
| Run one operation now | System administration > Periodic tasks > Lattice > Process async operations, field Tracking ID | None |
On the Background processes tab the process shows as Lattice Async Operation Processing, with the type Lattice Async Operation Processor. The Process automations page is a standard page that only the System administrator role opens.
Process async operations runs one operation by its tracking ID. It needs the Integration administrator role, is refused while the license blocks Lattice, and runs the operation only while it is still Queued: for an operation in any other status it does nothing.
Two values are fixed and have no setting: an operation counts as interrupted after 60 minutes in Processing, and an interrupted operation is queued again at most once.
How it works
- Recover interrupted operations. For each operation that has been Processing for more than 60 minutes and
whose own batch job is no longer executing, the process reads the idempotency claim of the request inside the
operation's payload:
- The claim shows the request succeeded: the operation becomes Succeeded with the document, and its message reads "The operation completed, but its result was not recorded. The result was recovered from the idempotency log."
- There is no claim (the operation never started posting, or it failed and released its claim) and it has not been queued again before: it becomes Queued again, with the message "Processing of the operation stopped before it started posting, so it was queued again."
- The claim is still Processing and less than 60 minutes old: the operation is still running and is left alone.
- In every other case (the payload has no request ID, the claim is stale, or the operation was already queued again once): it becomes Failed with the error code Request needs review and is parked in the dead-letter queue, with the message "Processing of the operation stopped without a result, and it cannot be determined whether it posted. Check the target documents before you replay it from the dead-letter queue."
- Check the license. If it blocks Lattice processing, stop here.
- List the work. One batch task for each Queued operation, all in one batch job named Lattice async operation processor.
- Claim the operation. Each task takes its operation from Queued to Processing under a row lock. If the operation's own batch job claimed it first, the task leaves it alone, so an operation never runs twice.
- Check it may still run. The operation must still be enabled in the async operation registry, and the user who submitted it must still hold access to the target operation (roles can change while it waits). If not, it becomes Failed with the reason and is parked in the dead-letter queue.
- Read the payload and find the handler. A payload that cannot be read, or an operation no handler runs, makes it Failed and parked, with the error code Validation failed.
- Run the target operation with the stored payload:
- Success: Succeeded, with the document and posted document numbers and the operation's message.
- The operation reports a failure: Failed, with its message, error details and error code (Business rule when it gives none). The item goes to the dead-letter queue as Retrying when the operation marks the failure retryable, otherwise as Parked.
- An error is raised while it runs: Failed, with the message "Async operation failed with an unhandled error." The item goes to the dead-letter queue as Retrying, error code Transient runtime error.
Before it can run
- Process automation is initialized in the environment (System administration > Setup > Initialize process automations), and Lattice was deployed with a database synchronization, which registers the process.
- A batch server is running (System administration > Setup > Server configuration).
- The Lattice license does not block processing.
- The operation is enabled on Async operation registry.
- The user who submitted the operation holds the privilege for the target operation, the same access a direct call needs. It is checked when the operation is submitted and again just before it runs.
Inputs and outputs
| Reads | Changes or creates |
|---|---|
| Async operations in Queued and Processing | The operation's Status, Message, document numbers, error code and Completed time |
| Async operation registry (enabled or not) | A dead-letter item (Source Async operation) for each failed operation, Retrying or Parked |
| The idempotency claim of the request inside the payload (recovery only) | The Integration item parked business event when an item is parked and the event is activated |
| The batch job of each interrupted operation (recovery only) | The documents the target operation creates and posts |
Monitoring and logs
- System administration > Inquiries > Lattice > Integration operations > Inbound message inquiry, Async operations tab: Tracking ID, Service, Operation, Status, Submitted time, Completed time and Message, with Download request payload. All four Lattice integration roles can open it.
- Failed operations in the dead-letter queue: the Dead letters awaiting action tile on the Integration operations workspace, and Integration operations console filtered on Source Async operation.
- The
LatticeAsyncOperationTrackingRecordsentity (/data/LatticeAsyncOperationTrackingRecords), readable by all four Lattice integration roles, and thegetAsyncOperationStatusoperation for callers. - System administration > Inquiries > Batch jobs: the background process's jobs are named Lattice async operation processor; each submission's own job is named Lattice async: followed by the service, the operation and the tracking ID.
- When Application Insights telemetry is set up for the environment:
Lattice.Async.StaleRecoveredfor each recovered operation (ids and the action taken, never the payload), and an exception record when an operation could not be recovered or its failure could not be recorded.
Finished operations (Succeeded and Failed) are deleted 30 days after they were submitted by the Lattice integration log cleanup.
When it fails
Each operation runs as its own batch task, so one operation's failure is recorded on its own row and the others carry on. The recovery settles each interrupted operation separately; one that cannot be settled is left for the next poll and the rest continue.
The Message column of Inbound message inquiry shows the outcome. When it reads "Async operation failed with
an unhandled error.", the reason is in the dead-letter item's Failure message (and in the Errors that
getAsyncOperationStatus returns).
| Symptom | Cause | Fix |
|---|---|---|
| Operations stay Queued | No batch server is running; process automation is not initialized, or the process was never registered because Lattice was deployed without the database synchronization that registers its processes; or the license blocks Lattice | Start the batch server, initialize process automation, deploy Lattice again through your build so the database synchronization runs, or restore the license. Queued operations then run within a minute. |
| Failed, Message: "The operation service.operation was not run because an administrator disabled it for async execution after it was queued. Enable it in the async operation registry, then replay it from the dead-letter queue." | The operation was switched off on Async operation registry after it was submitted | Enable it again if it is still wanted, then replay the parked item from Integration operations console. |
| Failed, Message: "The operation service.operation was not run because the user who submitted it (user) does not have access to that service operation." | The submitter lost the role that grants the operation while it waited | Decide whether the operation should still run. If so, choose Fix and resubmit on Dead-letter fix and resubmit (it runs with your access), or Retry now (it runs at the next poll of Lattice dead-letter retry, with the access of that process's owner). The submitter does not need the role back. |
| Failed, Failure message: "The request payload for service.operation could not be read, so the operation was not run. Correct the payload and replay it from the dead-letter queue." | The stored payload does not match the operation's request contract | Correct it on Dead-letter fix and resubmit and choose Fix and resubmit. |
| Failed, error code Request needs review, Message: "Processing of the operation stopped without a result, and it cannot be determined whether it posted. Check the target documents before you replay it from the dead-letter queue." | The server or batch task stopped while the operation ran, and Lattice cannot tell whether it posted | Look for the document in the target legal entity. If it posted, discard the dead-letter item. If it did not, first release any claim of the request that is still Processing on Service idempotency log (a replay under the same request ID is refused while that claim is open), then resubmit the item. |
| Failed, Failure message: "The operation failed due to an integration runtime error." (or "The operation failed due to a validation or business rule constraint.") | An error was raised while the target operation ran | Nothing at first: the dead-letter retry replays it. If it is parked after its attempts, find the cause in the target operation before you resubmit it. |
Effect on the rest of Lattice
- Two dispatchers can reach the same operation: its own batch job and this process. The row lock lets only the first one run it.
- While the license blocks Lattice, new submissions are refused with "The Magicite Lattice license is not valid (status status). Async operations cannot be submitted until it is renewed." Operations queued before the block wait; this process runs them once the license is restored. Without this process they would stay Queued, because their own batch job has already ended.
- Failed operations go to the dead-letter queue, where the Lattice dead-letter retry replays the retryable ones. A successful replay also sets the async operation to Succeeded, so a polling caller sees the real outcome.
- Each queued operation takes a batch thread while it runs. A burst of submissions competes with your other batch work for those threads.
Related
- I want to run a long posting in the background and collect the result
- I want to check an asynchronous operation
- I want to turn off an asynchronous operation
- I want to check that the Lattice background processes are running
- Send many requests at once, or run long work asynchronously
- submitAsyncOperation and getAsyncOperationStatus
- Turning off an asynchronous operation
- Lattice dead-letter retry