AXIS2-6103 Add streaming JSON message formatters for large HTTP responses
New package org.apache.axis2.json.streaming with three classes:
- FlushingOutputStream: wraps transport OutputStream, flushes every
64KB (configurable). Prevents reverse proxy 502 Bad Gateway on
large responses by converting a single buffered body into a stream
of HTTP/2 DATA frames or HTTP/1.1 chunks.
- JSONStreamingMessageFormatter: GSON variant. Drop-in replacement
for org.apache.axis2.json.gson.JsonFormatter.
- MoshiStreamingMessageFormatter: Moshi variant. Drop-in replacement
for org.apache.axis2.json.moshi.JsonFormatter.
Both formatters use try-with-resources for JsonWriter lifecycle
(addressed in Gemini code review). FlushingOutputStream uses long
for bytesSinceFlush counter to prevent int overflow on 2GB+ writes.
Enable globally in axis2.xml:
<messageFormatter contentType="application/json"
class="org.apache.axis2.json.streaming.MoshiStreamingMessageFormatter"/>
Optional per-service flush interval tuning in services.xml:
<parameter name="streamingFlushIntervalBytes">131072</parameter>
No service code changes required. Tested on WildFly 32 locally and
behind a reverse proxy on stg-rapi02 (HTTP/2 ALPN). All existing
services (BigDataH2Service, FinancialBenchmarkService) produce
bit-identical JSON results.
Also includes:
- json-streaming-formatter.xml: full user guide
- toc.xml: cross-referenced in JSON (23.6), HTTP/2 (18.6), and
MCP (23.4) sections
- springbootdemo-tomcat11 README: streaming formatter section
6 files changed