_message while the call body runs. This operation is only supported in Script connector templates.
Required Parameters
- messageId: The Id of the batch group message to iterate. Typically referenced as
[MessageId].
Optional Parameters
- messageType: The message type to use when reading batch members. Accepted values are
Auto,Input,Output, andTemp. The default isAuto, but read Always Set messageType to Input for best practice recommendations.OutputandTemptarget the script’s output and temporary message stores respectively; these are rarely needed.
Output Attributes
The following attributes are available on_message within the call body for each batch member:
- _message.body: The content of the batch member message.
- _message.header:*: The message headers of the batch member. For example,
[_message.header:filename]returns the filename header.
Related Attributes
- _message.isBatchGroup: Available on any
_messagein Script context. Returnstrueif the current message is a batch group; returnsfalseif it is a standard message. Useful for conditionally callingconnectorBatchGroupReadonly when the incoming message is a batch group.
Script Connector Usage
Always Set messageType to Input
When callingconnectorBatchGroupRead in a Script connector, always explicitly set messageType to Input:
messageType, the operation searches for the message Id among both the input message and any output messages the script is creating in the current run. If the script pushes output with a batchGroupKey before the call completes, an output batch group can be assigned the same message Id as the input. When that happens, the operation cannot determine which message you mean and fails with an error like the following:
Clear the Output Item Before Each Push
Output attributes are not cleared by arc:push; they carry over to the next push. Call<arc:unset item="output" /> before each push to avoid unexpected behavior.
Without clearing, a value set on one push can affect the next:
arc:unset also clears output.batchGroupKey. On the push that finalizes a batch group with output.isBatchGroup=true, set output.batchGroupKey again after the arc:unset.
Producing Batch Groups on Output
To send output as a batch group, setoutput.batchGroupKey on each member push. Members that share the same key are grouped together. If no explicit finalizer push is made, the Script connector creates the batch group automatically at the end of the run.
To define group-level properties (such as the group’s filename or headers), make an explicit finalizer push by setting output.isBatchGroup to true along with the same batchGroupKey. The finalizer emits the group at that point in the run rather than at the end.
Constraints on the finalizer push:
output.batchGroupKeymust match the key of an existing, non-empty pending group.output.dataandoutput.filepathare invalid and return an error because the group’s content is defined by its members.output.filenameand other message metadata remain valid.
Emission Order
- Regular output messages are emitted in push order.
- An explicit
isBatchGroup=truepush emits its group at that point in the run. - Any remaining implicit groups are emitted at the end of the run.
Examples
Read Batch Members as Regular Messages
Reads each member of the input batch group and emits it as a regular output message:Regroup Members into a New Batch Group
Reads each member, renames it, and emits all members as one new batch group namedbatch01:
batchGroupKey.