Quiz — Chapter 39: Real-Time Integration
Multiple Choice
1. What is the primary purpose of IBM MQ in a COBOL integration architecture?
a) To compile COBOL programs remotely b) To enable reliable asynchronous communication between applications c) To convert COBOL programs to Java d) To manage database connections
2. Which MQ API call is used to send a message to a queue?
a) MQSEND b) MQWRITE c) MQPUT d) MQPOST
3. In Enterprise COBOL 6.1+, which statement converts a COBOL data structure to JSON?
a) MOVE TO JSON b) JSON GENERATE c) WRITE JSON d) CONVERT TO JSON
4. What does the NAME clause do in a JSON GENERATE statement?
a) Names the output file b) Maps COBOL data names to custom JSON field names c) Creates a named JSON object d) Defines the program name in the JSON output
5. How does XML PARSE process XML data in COBOL?
a) It reads the entire XML into a COBOL structure at once b) It uses an event-based model with a processing procedure c) It converts XML to JSON first, then parses d) It requires an external XML library
6. In z/OS Connect, what role does the COBOL program play when exposed as a REST API?
a) It handles HTTP headers and authentication directly b) It processes business logic through a COMMAREA, unaware of HTTP c) It must include HTTP parsing code d) It directly manages TCP/IP connections
7. What is a dead letter queue?
a) A queue that has been deleted b) A queue where unprocessable messages are moved for investigation c) A queue that is no longer in use d) A queue with expired messages
8. Which numeric format should NOT be used directly in JSON output?
a) PIC 9(07)V99 DISPLAY b) PIC S9(07)V99 COMP-3 c) PIC 9(07).99 d) PIC ZZZZ,ZZ9.99
9. In the MQ request/reply pattern, how does the client match a response to its original request?
a) By message sequence number b) By correlation ID c) By queue name d) By timestamp
10. What is the SUPPRESS clause used for in JSON GENERATE?
a) To hide sensitive data fields b) To omit specified fields from the JSON output c) To compress the JSON d) To suppress error messages
True or False
11. COBOL programs must be rewritten to support REST API access. ____
12. IBM MQ supports communication between programs running on different platforms (e.g., z/OS and Linux). ____
13. JSON PARSE requires that the JSON field names exactly match the COBOL data names if no NAME clause is provided. ____
14. In an event-driven architecture, the message producer and consumer must run simultaneously. ____
15. Character encoding conversion between EBCDIC and UTF-8 is handled automatically by CICS Web Services. ____
Short Answer
16. Explain why integration happens "at the boundary" of a COBOL program rather than within its business logic.
17. Describe the difference between synchronous and asynchronous integration patterns. Give one example of each from the chapter.
18. Why is connection pooling important for MQ and HTTP integrations? What happens without it?
19. In the GlobalBank architecture, the COBOL program ACCTINQ is described as serving both 3270 terminals and mobile apps. How is this possible without changing the program?
20. Explain why COMP-3 (packed decimal) data cannot be sent directly in a JSON message.
Code Analysis
21. The following JSON GENERATE statement produces incorrect JSON field names for a modern API. What change would fix this?
01 WS-CUSTOMER.
05 CUST-FIRST-NAME PIC X(20).
05 CUST-LAST-NAME PIC X(20).
05 CUST-ACCT-BAL PIC S9(09)V99 COMP-3.
JSON GENERATE WS-JSON-OUTPUT
FROM WS-CUSTOMER
COUNT IN WS-JSON-LENGTH
END-JSON
22. The following MQ code has a problem with its MQGET loop. What is the issue?
PERFORM UNTIL WS-SHUTDOWN
CALL 'MQGET' USING ...
IF WS-COMPCODE = MQCC-OK
PERFORM PROCESS-MESSAGE
END-IF
END-PERFORM
Answer Key
1. b) To enable reliable asynchronous communication between applications
2. c) MQPUT
3. b) JSON GENERATE
4. b) Maps COBOL data names to custom JSON field names
5. b) It uses an event-based model with a processing procedure
6. b) It processes business logic through a COMMAREA, unaware of HTTP
7. b) A queue where unprocessable messages are moved for investigation
8. b) PIC S9(07)V99 COMP-3 — packed decimal is a binary format that cannot be represented as text
9. b) By correlation ID
10. b) To omit specified fields from the JSON output
11. False — COBOL programs can be exposed as REST APIs through infrastructure like z/OS Connect without code changes.
12. True — MQ is specifically designed for cross-platform communication.
13. True — without NAME clauses, JSON PARSE expects field names matching the COBOL data names (with hyphens).
14. False — message queuing decouples producers and consumers. They do not need to run simultaneously.
15. True
16. The business logic (account lookups, eligibility checks, transaction posting) does not change regardless of whether the input comes from a 3270 screen, an MQ message, or a REST API. Only the format of the input and output changes at the boundary. This separation of concerns keeps the tested, reliable business logic stable.
17. Synchronous: the caller waits for a response before continuing (e.g., balance inquiry API — the mobile app waits for the balance). Asynchronous: the sender puts a message and continues without waiting (e.g., transaction notification — the posting program sends a notification message and continues processing the next transaction).
18. Opening MQ connections and HTTP connections involves network handshakes, authentication, and resource allocation — this can take tens of milliseconds. Without pooling, each request incurs this overhead. With pooling (automatic in CICS), connections are reused across requests, reducing latency from tens of milliseconds to under a millisecond for the connection step.
19. The COBOL program communicates through a COMMAREA (a memory-based data structure). Both 3270 screens and REST APIs pass data through the same COMMAREA interface. The 3270 BMS map populates the COMMAREA from screen input; z/OS Connect populates it from JSON. The program does not know or care which interface supplied the data.
20. COMP-3 stores numbers in a packed decimal binary format (two digits per byte plus a sign nibble). This binary representation is not valid UTF-8 or ASCII text. If included directly in a JSON string, it would appear as garbled characters or could break JSON parsers. COMP-3 values must be converted to DISPLAY format (human-readable digits) before inclusion in JSON.
21. Add NAME clauses to produce camelCase field names expected by modern APIs:
JSON GENERATE WS-JSON-OUTPUT
FROM WS-CUSTOMER
COUNT IN WS-JSON-LENGTH
NAME OF CUST-FIRST-NAME IS 'firstName'
NAME OF CUST-LAST-NAME IS 'lastName'
NAME OF CUST-ACCT-BAL IS 'accountBalance'
END-JSON
22. The loop does not handle the MQRC-NO-MSG-AVAILABLE condition (timeout when queue is empty) or the MQRC-CONNECTION-QUIESCING condition. Without handling these, the loop will either spin continuously on timeouts without checking for shutdown conditions, or it will fail silently when the queue manager quiesces. The fix: add EVALUATE TRUE after the MQGET to handle MQCC-OK, MQRC-NO-MSG-AVAILABLE (check shutdown flag), MQRC-CONNECTION-QUIESCING (set shutdown), and OTHER (error handling).