Messaging & transactions · Intermediate

Data areas & message queues

Distinguish shared state, job-local state, and operator messaging.

Learn this topic first: Messaging, data queues, data areas and recovery →

6 explained questions · 5 practice MCQs

Questions and answers

1. What is a data area, and when is it useful? (Easy)

A data area stores a small piece of data accessible through IBM i interfaces. Applications use it for configuration, control information, or legacy shared values. It differs from a queue because it represents a current value rather than a sequence of work entries.

Define who may read or change it, its exact layout, and whether readers cache it. For structured or transactional state with history and queries, a database table is often easier to govern and evolve.

2. How does the local data area differ from a shared data area? (Easy)

The local data area is associated with a job and accessed using its special interface, rather than behaving like an ordinary named shared *DTAARA object. It is often used by legacy code to carry job-specific parameters or control values.

Do not expect unrelated jobs to observe the same local data area. Explicitly pass required context across submission boundaries and verify the relevant inheritance rules. For a new interface, typed parameters or a documented request record usually make dependencies clearer.

3. Which commands inspect and change data areas? (Intermediate)

DSPDTAARA displays a data area, RTVDTAARA retrieves data into CL variables, and CHGDTAARA changes values. Other interfaces, including RPG operations and APIs, can access data areas with their own locking conventions.

Treat its layout as a contract. A change to offsets, length, or numeric representation can break old programs. Keep configuration changes auditable, and do not assume a read-modify-write sequence is atomic merely because the storage object is small.

4. How do you prevent lost updates to a shared counter? (Intermediate)

Protect the entire read-modify-write critical section using the appropriate data-area locking protocol followed by reliable release. Without that protection, two jobs can read the same value and both write the same incremented result.

For new designs, consider a database identity, sequence, or transactional row update that better expresses the requirement. Define crash recovery and whether gaps are acceptable. A requirement for unique IDs is different from a requirement for gapless legal document numbering.

5. How is a message queue different from a data queue? (Intermediate)

A message queue supports IBM i messages with types, identifiers, routing, and potentially replies. It is suited to operational and program messaging. A data queue transports application entries in a producer-consumer design.

Choose based on semantics. An operator inquiry belongs in a message workflow; a high-volume work stream needs an explicit transport and processing contract. Neither object automatically substitutes for a full transactional business ledger.

6. Why is a data-area switch not always a safe deployment control? (Advanced)

A shared switch can be read at different times or cached by different jobs. Changing it may cause some requests to use old behavior and others new behavior while a single business operation is still in progress.

Define when configuration is sampled and record its version with the run or request. For incompatible schema or interface changes, coordinate deployment rather than hoping a flag prevents mixed versions. Test a flag change during a long-running batch and specify the expected behavior.

Practice checkpoint

  1. 1. Which object best represents one small shared current value?
    1. Job queue
    2. Binding directory
    3. Output queue
    4. Data area
  2. 2. Which command displays a data area?
    1. DSPDTAARA
    2. DSPSRVPGM
    3. CRTPGM
    4. WRKJOBSCDE
  3. 3. What must be protected for a shared increment?
    1. Only the final screen display
    2. The entire read-modify-write sequence
    3. Only the source compile
    4. Nothing if the field is numeric
  4. 4. Which object supports inquiry messages and replies?
    1. Binding directory
    2. Logical file index
    3. Message queue
    4. Memory pool
  5. 5. Can a configuration flag change affect jobs at different times?
    1. No, every job reads simultaneously
    2. Only if names differ
    3. Only without CL
    4. Yes, especially with cached state
Show answer key and explanations

1. D — Data area Data areas store current data rather than a sequence of work entries.

2. A — DSPDTAARA DSPDTAARA is the display command for a data area.

3. B — The entire read-modify-write sequence Locking only one part leaves a lost-update race.

4. C — Message queue Message queues provide message types and reply-oriented workflows.

5. D — Yes, especially with cached state Sampling and invalidation must be defined explicitly.

IBM documentation and further reading