Skip to content

Set Up ​

VersionMin runtime versionCompatible Java versionsDescription
1.0.04.9.6Java 17Latest release: chunking by delimiter, streaming strategies with limits in chunks, and typed errors

Earlier versions remain on Maven Central. 1.0.0-beta1 was a preview of 1.0.0; the one change since it is the connector's icon. To move an application from 0.2.0, see Upgrade from 0.2.0.

Requirements ​

Mule Runtime 4.9.6 or later, and Java 17.

Installation ​

Step 1: Add the Maven dependency ​

Add the following dependency to your Mule application's pom.xml:

xml
<dependency>
    <groupId>com.mulesoftforge</groupId>
    <artifactId>mule-chunking-connector</artifactId>
    <version>1.0.0</version>
    <classifier>mule-plugin</classifier>
</dependency>

TIP

The snippet above always shows the latest release on Maven Central, currently 1.0.0. To build from source instead, see the GitHub repository.

Step 2: Use the operation ​

The connector needs no global configuration element and no config-ref. Add read-chunked to a flow; with no settings it cuts the message payload into chunks of 1 MB, and foreach processes them one at a time:

xml
<chunking:read-chunked/>
<foreach>
    <logger level="INFO" message="#['Chunk $(payload.index): $(payload.length) bytes, last: $(payload.last)']"/>
</foreach>

To choose how the content is cut and how the chunks are held, see read-chunked.

Sample application ​

The connector repository includes a sample application with one flow for each feature. It needs no external system, credential or network service: its input data is bundled with it, and each flow is started by an HTTP request to localhost.

In Anypoint Studio, use File > Import > Anypoint Studio > Anypoint Studio project from File System, and choose the examples/chunking-sample-app directory. In Anypoint Code Builder, open the examples/chunking-sample-app directory as a folder; it is recognised as a Mule project.

Run the application, then open http://localhost:8081/<flow name> in a browser. Each flow answers with a JSON summary of what it saw, and logs each chunk at INFO. Each flow also has an MUnit test.

FlowWhat it shows
bare-operationThe operation with no settings: 1 MB chunks, non-repeatable
by-sizeChunks of 256 bytes
by-delimiter-default-newlineTen lines per chunk, the newline delimiter being the default
by-delimiter-expressionA delimiter that cannot be typed (the record separator, 0x1E), given as an expression
short-chunk-max-chunk-sizeA chunk ended early by maxChunkSize, seen through recordCount, with no error
streaming-non-repeatableRead once: a second pass sees no chunks
streaming-sliding-windowBoth routes of a scatter-gather read every chunk, with readers="2"; each chunk is let go once both have read it
streaming-in-memoryFully repeatable: two passes, at most 20 chunks in memory
streaming-file-store2 chunks in memory and the rest on disk, read by both routes of a scatter-gather
error-invalid-chunk-sizeCHUNKING:INVALID_CHUNK_SIZE caught by type
error-invalid-records-per-chunkCHUNKING:INVALID_RECORDS_PER_CHUNK caught by type
error-invalid-delimiterCHUNKING:INVALID_DELIMITER caught by type
error-invalid-parameterCHUNKING:INVALID_PARAMETER for an unknown encoding
error-parent-typeA handler for CHUNKING:INVALID_PARAMETER catching CHUNKING:INVALID_CHUNK_SIZE
error-no-contentCHUNKING:READ_ERROR when there is no content
error-failure-while-readingA record larger than maxChunkSize, failing while foreach reads, handled with ANY

Logging ​

The connector logs nothing at INFO; INFO lines are left to your application's flows.

LevelWhat the connector logs
DEBUGOne line for each invocation of read-chunked, with its chunking and streaming strategies and their settings; a line for each chunk read; when file-store starts writing to its temporary file, and when it deletes it; and what sliding-window held when it lets go of the chunks
WARNThe content could not be closed after reading, or file-store could not delete its temporary file

Failures a flow must handle are raised as errors and are not logged. See Errors.

To see the DEBUG lines, set the logger com.mulesoftforge.mule.extension.chunking to DEBUG in your application's log4j2.xml.

Site content released under the Apache License 2.0. Each asset carries its own license. RSS · llms.txt