7.6: Chunking
7.6 Processing Protocol for Partial Messages (Chunking)
This section describes the protocol for splitting (by the sender) and processing (by the recipient) large messages. The use of partial messages (chunks) is an optional mechanism that is applied when the size of a message exceeds the agreed limits.
7.6.1 Fundamental Principles of Chunking
Before we describe the splitting and merging process, the following fundamental rules apply to the chunking mechanism:
-
Validity per Chunk: Each chunk must be a self-contained message that fully conforms to the JSON schema. This means that each chunk contains all mandatory "header" blocks, such as commonTechnical and commonFunctional.
-
Shared messageId: All chunks that are part of one logical message share exactly the same messageId in the commonTechnical block. This is the unique identification of the overarching, logical message.
-
Mandatory chunking attributes: If the chunking.default entity is present to indicate that chunking is applied, all attributes within this entity are mandatory. This is essential for a robust and deterministic reconstruction process on the recipient's side.
-
Integrity of the logical message: An error in a single chunk (e.g. a validation error or the chunk not arriving) makes the entire logical message invalid. The message must then be offered again in its entirety, with a new messageId.
7.6.2 Splitting a Large Message (Sender Side)
1. Determining the Need
Splitting is necessary when a message exceeds the agreed maximum size (default: 4 MB). The sender is responsible for dividing the data correctly.
2. The Splitting Process
The sender creates several chunks by dividing the data from large, repeating arrays (such as the list of cohorts). Each chunk is given a chunking block with the correct metadata (chunkSequenceNumber, totalNumberOfChunks, etc.) and the chunkFragmentPaths that describe the content of that specific chunk.
3. Use of JMESPath in chunkFragmentPaths
The chunkFragmentPaths field contains the essential instructions for the recipient to be able to reconstruct the original message correctly. The JMESPath can indicate a specific range (slice) (e.g. pension[0:100]), which guarantees that the recipient can put the data back in exactly the right order, even if the chunks are received in a different order.
7.6.3 Processing Received Chunks (Recipient Side)
1. The Reconstruction Process
The recipient uses the shared messageId to collect chunks
-
Start with the First Chunk: The chunk with chunkSequenceNumber: 1 serves as the basis or 'template' for the reconstruction.
-
Place Data Fragments: For all subsequent chunks, the data fragments are placed in the right position in the template, guided by the chunkFragmentPaths.
-
Determine Completeness: The message is complete when the number of chunks received is equal to totalNumberOfChunks.
2. Processing Strategies
After conceptual completeness, the recipient can choose between:
-
Reconstruction first (Batch approach): Build the complete message in memory and validate it afterwards.
-
Streaming processing (Direct processing): Store data fragments directly per chunk and carry out overarching validations later on the database.
3. Error Handling and Incompleteness
The integrity of the complete logical message is crucial.
-
If a single chunk fails (for example because of a technical validation error, or if it is not received within a certain time), the entire logical message is regarded as failed and unprocessable.
-
In that case, the sender must, after consultation if needed, offer the complete message again with a new messageId, split into a new set of chunks.