CICS

CICS TDQ Trigger Levels: Diagnose Duplicate Work Before Changing the Queue Definition

A CICS transient data queue (TDQ) can be part of a reliable handoff from an online transaction to deferred processing. When the receiving work appears twice, however, the queue definition is an easy target and often the wrong one. This runbook shows how to separate duplicate producer execution, trigger-level behavior, and consumer recovery before changing a TDQ or replaying work.

Terminal inputCICS taskValidationSafe response
Original DBala learning flow — a visual summary of this article’s practical decision path.

A CICS transient data queue (TDQ) can be part of a reliable handoff from an online transaction to deferred processing. When the receiving work appears twice, however, the queue definition is an easy target and often the wrong one. This runbook shows how to separate duplicate producer execution, trigger-level behavior, and consumer recovery before changing a TDQ or replaying work.

The queue IDs, transaction names, and values below are fictional. TDQ definitions, automatic transaction initiation (ATI), recovery settings, and monitoring tools vary by CICS release and local standards. Do not purge a production queue, disable a trigger, resubmit a producer transaction, or restart a consumer merely because duplicate-looking records are present.

Trigger: the downstream transaction processed an apparent duplicate

Assume an order-entry transaction writes an event to intrapartition TDQ ORDQ. The queue has a trigger level of 1 and is associated with transaction ORDP. When the queue depth reaches the trigger condition, CICS can start the named transaction to consume the queued work.

A support report says order A10482 was processed twice. There are at least three materially different explanations:

| Observation | What it may mean | Unsafe assumption to avoid |
| --- | --- | --- |
| Two identical queue records exist | The producer wrote twice, or a retry wrote again | The trigger level duplicated a record |
| One record exists, but two business updates exist | The consumer retried after an uncertain outcome or lacks idempotency | The queue is necessarily at fault |
| A consumer starts more than once while work remains | Normal ATI scheduling or another start path may be involved | Every started task should process the same record |
| Queue depth rises and no consumer runs | Trigger configuration, availability, security, or transaction enablement needs investigation | Rewriting the producer will solve it |

A trigger level controls *when CICS requests transaction initiation based on queue state*. It does not itself create a second copy of a queued record. That distinction is useful because deleting or redefining a queue can destroy the evidence needed to identify where duplication entered the flow.

First establish the handoff contract

Write down the intended unit of work in plain language. For this example: one accepted online request should create one event with a unique request ID; one consumer should apply the business action once; successful processing should leave enough evidence to prevent a replay from creating a second action.

The producer might use a compact CICS command like this:

       MOVE 'ORDQ' TO WS-TDQ-NAME
       MOVE WS-ORDER-EVENT TO WS-TDQ-RECORD

EXEC CICS
WRITEQ TD QUEUE(WS-TDQ-NAME)
FROM(WS-TDQ-RECORD)
LENGTH(LENGTH OF WS-TDQ-RECORD)
RESP(WS-RESP)
RESP2(WS-RESP2)
END-EXEC

IF WS-RESP NOT = DFHRESP(NORMAL)
PERFORM HANDLE-TDQ-WRITE-FAILURE
END-IF
```

A NORMAL response proves that the command returned successfully; it does not prove that the later business action completed exactly once. Conversely, a non-normal response must not automatically cause a blind retry. The original write may have reached a recoverable boundary even when the caller cannot yet establish the final state. The local application recovery design determines the safe response.

The record should carry a stable business or request identifier such as REQUEST-ID, not just an order number and timestamp. A consumer can then record or test that identifier before applying an update. The mechanism might be a processed-event table with a unique key, an existing business-state version check, or another approved idempotency pattern. A queue protects delivery order; it does not automatically make an update idempotent.

Evidence to capture before any intervention

Collect evidence for one affected request and a narrow time window. Use local controls for any business data; identifiers, timestamps, sequence values, and response codes are usually more useful than full payloads.

Avoid treating an application log line saying “received event” as proof of a durable business update. The useful boundary is the application’s committed state, not just the point where a program read a record.

Diagnosis path: count records and effects separately

Use this short flow rather than jumping directly to the TDQ definition:

One request ID reported twice
        |
        +-- Are there two distinct producer write confirmations or queue entries?
        |       |
        |       +-- Yes: trace producer retry path and request acceptance controls.
        |       +-- No: continue.
        |
        +-- Did the consumer attempt the same request ID more than once?
                |
                +-- No: inspect downstream reporting or correlation logic.
                +-- Yes: did the first attempt commit the business action?
                         |
                         +-- Yes: idempotency or duplicate-detection control failed.
                         +-- No/unknown: follow the documented recovery path; do not replay blindly.

If two TDQ records contain the same request ID, look upstream first. Common causes include a user resubmitting after a timeout, a program retrying a WRITEQ TD without an outcome check, or two entry paths both accepting the same request. The trigger level may explain why a consumer started promptly, but not why two records exist.

If only one record was written but the consumer performed the action twice, inspect the consumer’s transaction boundaries. A consumer that performs an external call or database update, then fails before recording its completion marker, may be unable to distinguish a safe retry from a duplicate action. The repair is normally in the business recovery and idempotency design, not by raising the trigger level.

Trigger level can still matter operationally. A very low level can cause frequent consumer starts for small bursts; a higher level can defer processing until enough work accumulates. Neither value is universally correct. Select it from latency, throughput, concurrency, and recovery requirements, then test it with realistic arrival patterns. Do not change it in production as an unmeasured response to one incident.

Safe correction options

| Finding | Correction direction |
| --- | --- |
| Producer accepts the same request twice | Add or repair a request-level duplicate check at the acceptance boundary; preserve a meaningful response for a genuine repeat. |
| Producer retry cannot tell whether a write committed | Use the application’s approved recoverable design and correlation evidence; do not add unconditional retries. |
| Consumer can reapply a committed request | Make processing idempotent with a unique request ID or business-state guard, and test recovery after each boundary. |
| ATI is not starting an eligible consumer | Review the controlled TDQ and transaction definitions, enablement, security, and region health with the CICS administrator. |
| Trigger level does not meet service needs | Change it only through normal configuration review, capacity testing, and rollback planning. |

For command semantics and attributes, consult the IBM CICS documentation for WRITEQ TD, transient data queue definitions, and automatic transaction initiation for the installed release. Product behavior and operational controls can differ across environments.

Before replaying or changing the queue

Practical takeaway

A TDQ trigger level decides when deferred work is invited to run; it is not a duplicate-record generator. Prove separately how many events were written, how many times the consumer attempted them, and what business effects committed. That evidence leads to a safer fix than changing a queue definition or rerunning work on assumption.

← Back to all articles