<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Practical Quarkus]]></title><description><![CDATA[Real-world Java & Quarkus guides, code examples, and production lessons. Building fast, cloud-native Java backends with Quarkus step-by-step guides and architec]]></description><link>https://nicolasduminil.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Dec 2026 00:53:24 GMT</lastBuildDate><atom:link href="https://nicolasduminil.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Putting HTTP/3 in Quarkus 4 to the Test]]></title><description><![CDATA[HTTP/3 is the third major version of the Hypertext Transfer Protocol. It preserves the semantics that web developers already know, namely methods, status…]]></description><link>https://nicolasduminil.hashnode.dev/putting-http-3-in-quarkus-4-to-the-test</link><guid isPermaLink="true">https://nicolasduminil.hashnode.dev/putting-http-3-in-quarkus-4-to-the-test</guid><dc:creator><![CDATA[nicolasduminil]]></dc:creator><pubDate>Thu, 03 Dec 2026 16:40:46 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>HTTP/3 is the third major version of the Hypertext Transfer Protocol. It preserves the semantics that web developers already know, namely methods, status codes, header fields and message bodies, while it replaces the transport on which these semantics travel. HTTP/1.1 and HTTP/2 rely on the Transmission Control Protocol (TCP), whereas HTTP/3 relies on QUIC, a transport protocol standardized by the Internet Engineering Task Force in RFC 9000 and built on top of the User Datagram Protocol (UDP).</p>
<p>Quarkus 4.0, released in November 2026, introduces an experimental extension named <code>quarkus-http3</code>. With this extension, a Quarkus application serves HTTP/1.1, HTTP/2 and HTTP/3 on one and the same HTTPS port, the first two over TCP and the third over UDP, and a Quarkus REST client is able to call remote services over HTTP/3.</p>
<p>This article studies that extension through a small but realistic application, a service that delivers the many small images of a web page, and through a benchmark that measures what HTTP/3 changes in practice. The article pays particular attention to header compression, which HTTP/2 performs with HPACK and HTTP/3 performs with QPACK, and to the number of network round trips that each protocol requires before the first byte of a response reaches the client, which this article calls the round trip time (RTT) budget of a request.</p>
<p>The article also reports several defects of the extension in its version 4.0.1, together with a defect of the QUIC implementation on which it relies. It tries to explain these defects root causes, and presents the workarounds that the project applies. It concludes that the support of HTTP/3 in Quarkus 4.0.1 conforms to the specifications but has not yet reached the maturity that production use requires, mainly because some requests never complete on networks that lose packets. The complete source code is available in the accompanying GitHub repository, <a href="https://github.com/nicolasduminil/http3-quarkus">nicolasduminil/http3-quarkus</a>.</p>
<h2>From HTTP/1.1 to HTTP/3</h2>
<p>Each version of HTTP addresses a limitation of its predecessor. This section therefore follows that evolution, from the multiple connections of HTTP/1.1 through the multiplexing of HTTP/2 to the replacement of TCP by QUIC.</p>
<h3>HTTP/1.1 and the cost of connections</h3>
<p>HTTP/1.1 transmits one request at a time on a TCP connection and waits for the complete response before sending the next request on the same connection. Browsers compensate for this sequential behavior by opening several connections to the same origin, typically six. Each connection, however, requires its own TCP handshake and its own TLS handshake, and each connection discovers the available bandwidth independently through the slow start mechanism of TCP congestion control.</p>
<h3>HTTP/2 and multiplexing</h3>
<p>HTTP/2, standardized in RFC 9113, multiplexes many concurrent requests on a single TCP connection. Each request and its response form a stream, identified by a stream number, and the frames of all streams are interleaved on the connection. HTTP/2 also introduced HPACK, a header compression scheme that removes most of the redundancy between the header fields of successive requests.</p>
<h3>Head of line blocking in TCP</h3>
<p>TCP offers an ordered byte stream. When a segment is lost, the receiving TCP stack withholds every subsequent byte from the application until the retransmission of the lost segment has arrived, even when those subsequent bytes belong to other HTTP/2 streams that are complete. This phenomenon is called <em>transport level head of line blocking</em>. On a reliable network it remains invisible, but on a network that loses packets, a single loss delays every response multiplexed on the connection.</p>
<p><img src="https://raw.githubusercontent.com/nicolasduminil/http3-quarkus/master/diagrams/03-head-of-line-blocking.png" alt="Head of line blocking in TCP compared with independent QUIC streams" /></p>
<h3>HTTP/3 and QUIC</h3>
<p>QUIC moves stream multiplexing into the transport itself. Each HTTP/3 request travels on its own QUIC stream, and QUIC delivers the data of each stream as soon as that stream is complete, independently of losses that affect other streams. QUIC integrates TLS 1.3 into its own handshake, so that a single exchange establishes both the transport state and the encryption keys. QUIC is implemented in user space on top of UDP, which allows it to evolve without changes to operating system kernels, at the cost of a higher processing load than the kernel implementation of TCP.</p>
<p><img src="https://raw.githubusercontent.com/nicolasduminil/http3-quarkus/master/diagrams/01-protocol-stacks.png" alt="Protocol stacks of HTTP/1.1, HTTP/2 and HTTP/3" /></p>
<p>QUIC provides several further mechanisms which we're referencing later. Connection identifiers allow a connection to survive a change of the client address, for example when a mobile device moves from a wireless network to a cellular network, a mechanism called connection migration. Session resumption with 0-RTT allows a client that has already connected to a server to send its first request together with its first handshake packet. Address validation allows a server to verify that a client really owns the source address of its packets before the server sends large amounts of data to that address.</p>
<h2>Discovering HTTP/3: the Alt-Svc mechanism</h2>
<p>A client that receives a URL beginning with <code>https://</code> has no prior knowledge that the server supports HTTP/3. The client therefore starts with TCP, and the server advertises HTTP/3 through an alternative service, defined in RFC 7838. The advertisement takes the form of a response header field:</p>
<pre><code>Alt-Svc: h3=":8443"; ma=3600
</code></pre>
<p>This field states that the same origin is reachable with the protocol identified as <code>h3</code> on port 8443 of the same host, and that the client may remember this information for 3600 seconds. RFC 7838 also defines an <code>ALTSVC</code> frame for HTTP/2, which conveys the same information outside any response header block. Browsers use the advertisement for subsequent requests, which explains why the first page load of a new site usually happens over HTTP/2 and the following ones over HTTP/3.</p>
<p><img src="https://raw.githubusercontent.com/nicolasduminil/http3-quarkus/master/diagrams/02-alt-svc-discovery.png" alt="Discovery of HTTP/3 through the Alt-Svc response header" /></p>
<h2>Header compression: HPACK and QPACK</h2>
<p>Header compression is one of the subjects that we're examining here in detail. This section explains why the header fields of HTTP deserve compression, presents the principles common to HPACK and QPACK, and shows why the independent streams of QUIC required QPACK to replace HPACK. It also describes how Quarkus 4.0.1 applies QPACK in practice.</p>
<h3>Why header compression matters</h3>
<p>A modern web page issues dozens of requests to the same origin, and each request carries header fields such as the user agent, the accepted media types, cookies and caching directives. Responses carry security policies, caching directives and entity tags. These fields repeat almost identically from one exchange to the next, and on a page of small resources, such as the map tiles of this project, the header fields can represent a significant share of the transferred bytes.</p>
<h3>Principles of header compression</h3>
<p>A header field is a pair formed by a name and a value, such as <code>content-type: image/png</code>. The request or response header fields can be compressed and, then, they form a header block.</p>
<p>Header compression involves two components on each connection:</p>
<ul>
<li>an <em>encoder</em> that belongs to the sender of a message and converts its list of header fields into a compact header block; </li>
<li>a <em>decoder</em> that belongs to the receiver and reconstructs the original list from that block.</li>
</ul>
<p>Each direction of a connection has its own pair: the encoder of the client and the decoder of the server process the requests, while the encoder of the server and the decoder of the client process the responses.</p>
<p>The encoder has tables in which it stores header fields and replaces them, in exchanges, by their associated references. There are two kind of tables: static and dynamic. The static table is a fixed list of common header fields defined by the specification of the protocol. Every implementation contains the same static table, which never changes, and the encoder designates one of its entries by a number called an index. The decoder has the same static tables. The dynamic table starts empty when the connection opens. The encoder inserts into it the header fields that it expects to send again, and it instructs the decoder to perform the same insertions in the same order, so that both components hold identical copies of the table. A header field already present in the dynamic table then travels as an index of one or two bytes. The dynamic table has a maximum size, and the oldest entries leave it when a new entry requires their space.</p>
<p>A header field that neither table contains travels as a literal, that is, as its name and its value written out. The encoder may still reference the name alone in a table and write only the value. Finally, the encoder may apply to each literal string a compression technique, named Huffman coding, that shortens it.</p>
<h3>HPACK</h3>
<p>HPACK, defined in RFC 7541, applies these techniques to HTTP/2. Its static table contains 61 entries, such as <code>:method: GET</code> or the name <code>content-type</code> without a value. When its encoder sends a literal header field, it can ask the decoder to insert the field into its copy of the dynamic table. The decoder chooses the maximum size of this table, 4096 bytes by default.
HPACK relies on a strict assumption: the decoder processes header blocks in exactly the order in which the encoder produced them, because each block may modify the dynamic table that the next block uses. TCP guarantees this order, since HTTP/2 transmits all frames of a connection on a single ordered byte stream.</p>
<h3>Why HTTP/3 needs QPACK</h3>
<p>QUIC delivers each stream independently. If HTTP/3 reused HPACK, a header block arriving on one stream could reference a dynamic table entry inserted by a block that is still in transit on another stream, and the decoder would have to wait for that other stream. Header compression would then reintroduce exactly the head of line blocking that QUIC removes.</p>
<p>QPACK, defined in RFC 9204, resolves this problem by separating the modification of the dynamic table from its use. The encoder sends table insertions on a dedicated unidirectional stream, called the encoder stream, and the decoder acknowledges them on another unidirectional stream, called the decoder stream. Each header block declares the number of insertions it requires, the Required Insert Count. A request stream whose header block references entries that have not yet arrived is blocked, and only that stream waits. The decoder announces how many streams it accepts to block through the setting <code>SETTINGS_QPACK_BLOCKED_STREAMS</code>, and the size of its dynamic table through <code>SETTINGS_QPACK_MAX_TABLE_CAPACITY</code>. The encoder may also decide to reference only entries already acknowledged, which avoids blocking entirely at the cost of a lower compression ratio. QPACK provides a larger static table than HPACK, with 99 entries, and keeps Huffman coding.</p>
<p><img src="https://raw.githubusercontent.com/nicolasduminil/http3-quarkus/master/diagrams/06-qpack-streams.png" alt="QPACK encoder and decoder streams, and the behaviour of Vert.x 5.2.3" /></p>
<h3>QPACK in Quarkus 4.0.1</h3>
<p>Quarkus serves HTTP/3 through Eclipse Vert.x 5.2.3, which delegates the protocol to Netty 4.2.20. Netty implements HTTP/3 and QPACK in Java, and relies for the QUIC transport on <code>quiche</code>. This is the open source QUIC implementation written in Rust by Cloudflare, which Netty ships as a native library. The QPACK encoder of Netty supports the dynamic table. Vert.x, however, disables dynamic tables by creating the Netty HTTP/3 connection handler with the parameter <code>disableQpackDynamicTable</code> set to <code>true</code>. This is also the default of Netty, in every version from 5.1.0 to 5.2.3, and neither Vert.x nor Quarkus exposes an option to change it, such that to enable dynamic tables. The HTTP/3 server of Quarkus therefore compresses response headers with the static table and with Huffman coding only, and its dynamic table stays empty. While this choice simplifies the implementation and excludes blocked streams, it reduces however the compression ratio for header fields that the static table does not contain.</p>
<p>The HPACK encoder of Netty, used for HTTP/2, populates the dynamic table. Consequently, in this implementation, HTTP/2 uses a dynamic table whereas HTTP/3 doesn't. The benchmark measures the effect of this difference with a dedicated measurement, presented later.</p>
<h2>The Quarkus HTTP/3 extension</h2>
<p>The extension <code>quarkus-http3</code> covers both sides of an exchange. On the server side, it adds a QUIC listener next to the existing HTTPS listener, and on the client side, it allows the Quarkus REST client to call a remote service over HTTP/3. This section presents the configuration that each side requires.</p>
<h3>Enabling HTTP/3</h3>
<p>The extension requires one dependency:</p>
<pre><code class="language-xml">&lt;dependency&gt;
  &lt;groupId&gt;io.quarkus&lt;/groupId&gt;
  &lt;artifactId&gt;quarkus-http3&lt;/artifactId&gt;
&lt;/dependency&gt;
</code></pre>
<p>With Maven, the extension also selects the native QUIC library of the build platform, <code>netty-codec-native-quic</code> with a classifier such as <code>linux-x86_64</code>, through Maven profile activation. An application built on one platform and deployed on another must declare the classifier of the target platform explicitly.</p>
<p>HTTP/3 mandates TLS 1.3. In development and test modes, the extension generates a certificate automatically when no TLS configuration exists, signed by the Quarkus development certificate authority when that authority is installed, and self-signed otherwise. In production mode, the application must configure TLS through its registry, with a PKCS12 key store, whose location and password come from environment variables:</p>
<pre><code class="language-properties">%prod.quarkus.tls.key-store.p12.path=${TLS_KEYSTORE:/certs/tile-service.p12}
%prod.quarkus.tls.key-store.p12.password=${TLS_KEYSTORE_PASSWORD}
</code></pre>
<p>The extension exposes three configuration properties: <code>quarkus.http3.enabled</code>, <code>quarkus.http3.alt-svc</code> and <code>quarkus.http3.alt-svc-max-age</code>. The server then listens on the HTTPS port, 8443 by default, for TCP connections carrying HTTP/1.1 and HTTP/2 and for UDP datagrams carrying QUIC.</p>
<h3>The REST client over HTTP/3</h3>
<p>A Quarkus REST client is a Java interface annotated with <code>@RegisterRestClient</code>. The attribute <code>configKey</code> of this annotation gives the client a name, which its configuration properties then reuse. In the following example, the operations of the client come from the interface <code>TileApi</code>, presented with the demonstration application:</p>
<pre><code class="language-java">@RegisterRestClient(configKey = "tiles-h3")
public interface TileH3Client extends TileApi {
}
</code></pre>
<p>The name of each property combines three parts. The prefix <code>quarkus.rest-client</code> is fixed and designates the REST client configuration. The middle part is the value of <code>configKey</code>, here <code>tiles-h3</code>, which selects the client that the property concerns. The last part is fixed and names the setting, such as <code>url</code> for the address of the target service or <code>http3</code> for the protocol. The client switches to HTTP/3 with the setting <code>http3</code>, and its target must be an HTTPS URL:</p>
<pre><code class="language-properties">quarkus.rest-client.tiles-h3.url=https://localhost:8443
quarkus.rest-client.tiles-h3.http3=true
</code></pre>
<p>The client connects with QUIC directly, without a preliminary TCP request and without consulting <code>Alt-Svc</code>, and it never falls back to TCP. When UDP is blocked between the client and the service, the request fails once the read timeout of the client expires, with a <code>ProcessingException</code> whose message reads "The timeout of N ms has been exceeded when getting a connection". The message mentions neither QUIC nor UDP, which deserves attention when diagnosing a firewall that filters UDP. A pure client application must also depend on <code>quarkus-http3</code>, because the client needs the native QUIC library, and the extension then starts an HTTP server and a QUIC listener in the client process as well.</p>
<h2>The demonstration application</h2>
<p>The concepts presented so far take a concrete form in a demonstration application, which the tests and the benchmark of this article exercise. This section describes the workload that the application serves, the Maven modules that compose it, the way it reports the protocol of each exchange and its errors, and a browser page that shows HTTP/3 at work.</p>
<h3>The use case</h3>
<p>The application reproduces a common workload of the web: a page that displays many small images at once. A photo gallery, a product catalogue and an interactive map share this pattern, in which the browser requests dozens of images of a few kilobytes at the same moment. This workload is precisely the one where the multiplexing of HTTP/2 and HTTP/3, and the head of line blocking that distinguishes them, make a measurable difference.</p>
<p>The project takes the map described above as its concrete example. This map is too big to be displayed entirely, accordingly, different parts of itself, called views, are displayed as a grid of tiles of 256 by 256 pixels. One view contains 8 by 8 tiles, that is 64 images of about 7 kilobytes each. The URL of each tile carries three integers, <code>/tiles/{z}/{x}/{y}.png</code>, where <code>z</code> selects the level of detail and <code>x</code> and <code>y</code> select the column and the row. </p>
<p>The content of the images is computed from a mathematical figure called <em>the Mandelbrot set</em>. This figure has been chosen because it has the property to produce a distinct image, for every tile, based on a short computation, without having to store or download files. The same image is always produced for the same tile.</p>
<h3>The Maven modules</h3>
<p>The project consists of a parent POM and six modules, as follows:</p>
<ul>
<li>the <code>tile-common</code> module contains the Jakarta REST interface shared by the server and the client, together with the records that describe tiles and grids;</li>
<li>the <code>tile-service</code> module contains the Quarkus application that renders the tiles;</li>
<li>the <code>tile-client</code> module contains a Quarkus command line application that fetches a page of tiles with a chosen protocol;</li>
<li>the <code>tile-map</code> module contains a web application that displays the map in a browser;</li>
<li>the <code>tile-server-support</code> module gathers the server-side code that <code>tile-service</code> and <code>tile-map</code> share, namely the protocol header fields, the HTTP/3 server settings and the error responses;</li>
<li>the <code>tile-testing</code> module provides the test container of <code>tile-service</code> to the modules whose tests need it;</li>
<li>the <code>benchmark</code> directory contains the benchmark tooling outside the Maven build.</li>
</ul>
<p>The shared interface defines the following operations:</p>
<pre><code class="language-java">@Path("/tiles")
public interface TileApi {

  String IMAGE_PNG = "image/png";
  String X_PROTOCOL = "X-Protocol";

  @GET
  @Path("/{z}/{x}/{y}.png")
  @Produces(IMAGE_PNG)
  RestResponse&lt;byte[]&gt; tile(@PathParam("z") int z,
    @PathParam("x") int x, @PathParam("y") int y);

  @GET
  @Path("/{z}/{x}/{y}/meta")
  @Produces(MediaType.APPLICATION_JSON)
  RestResponse&lt;TileMeta&gt; meta(@PathParam("z") int z,
    @PathParam("x") int x, @PathParam("y") int y);

  @GET
  @Path("/grid")
  @Produces(MediaType.APPLICATION_JSON)
  TileGrid grid(@QueryParam("z") int z, @QueryParam("x") int x,
    @QueryParam("y") int y,
    @QueryParam("size") @DefaultValue("8") int size);
}
</code></pre>
<p>The <code>tile</code> operation returns a PNG image. The <code>grid</code> operation returns an instance of the record <code>TileGrid</code>, serialized as JSON, which describes one view: its level of detail, the coordinates of its first tile, its size and the list of the paths of its <code>size</code> by <code>size</code> tiles, 64 by default. The <code>meta</code> operation returns a small JSON document together with a realistic set of about one kilobyte of response header fields, such as <code>Content-Security-Policy</code>, <code>Strict-Transport-Security</code> and <code>Cache-Control</code>. This last operation exists to measure header compression, because its header fields dominate its body.</p>
<p>The module <code>tile-service</code> implements the interface in <code>TileResource</code>, and <code>tile-client</code> declares three REST client interfaces that extend it, one for each protocol. The operations <code>tile</code> and <code>meta</code> return <code>RestResponse</code>, a specific type of Quarkus REST that carries the body of a response together with its status and its header fields. On the server side, <code>TileResource</code> uses it to add header fields such as <code>ETag</code> to the response. On the client side, it gives access to the header fields received, among which <code>X-Protocol</code>.</p>
<h3>Making the protocol visible</h3>
<p>The application code is identical for the three protocols, and Quarkus selects the protocol below the application. To make the protocol observable, a Vert.x filter adds the header field <code>X-Protocol</code> to every response, with the value <code>HTTP/1.1</code>, <code>HTTP/2</code> or <code>HTTP/3</code> taken from the request as the server received it. The same filter emits the <code>Alt-Svc</code> header field, for a reason explained in the next section.</p>
<pre><code class="language-java">void register(@Observes Filters filters) {
  filters.register(rc -&gt; {
    rc.addHeadersEndHandler(v -&gt; decorate(rc));
    rc.next();
  }, 100);
}
</code></pre>
<p>The callback registered with <code>addHeadersEndHandler</code> runs at the moment Vert.x is about to send the response head, after the application has set its status and its header fields. The filter covers the static demonstration page as well as the REST endpoints.</p>
<h3>Errors as Problem Details</h3>
<p>Every error response follows RFC 9457, Problem Details for HTTP APIs, with the media type <code>application/problem+json</code>. An invalid tile, for example a column that exceeds the number of columns of its level of detail, produces a status 400 with a stable problem type. Unknown paths produce a status 404 in the same format.</p>
<h3>Watching HTTP/3 in the browser</h3>
<p>Tests and measurements establish what the protocol does, but a browser shows it. The <code>tile-map</code> module is a web application that displays the 64 tiles of a view and the protocol that carried each of them. The application is itself served over HTTP/3: the browser receives its page and its updates from <code>tile-map</code> over HTTP/3, and loads the tiles directly from <code>tile-service</code>, also over HTTP/3.</p>
<p>The page is rendered by Qute, the template engine of Quarkus, through the Quarkus REST resource <code>MapResource</code>. Navigation relies on <code>htmx</code>, a small JavaScript library that supports AJAX-like partial updates, according to attributes placed on the HTML elements. Each button of the map declares the fragment it requests, the element it replaces, and the address that the browser keeps in its history:</p>
<pre><code class="language-html">&lt;button id="zoom-in" hx-get="/map?{viewport.zoomIn.query}"
  hx-target="#map" hx-swap="outerHTML"
  hx-push-url="/?{viewport.zoomIn.query}"&gt;Zoom in&lt;/button&gt;
</code></pre>
<p>The Qute template defines the map as a fragment of the page, so that the resource renders either the complete page or the map alone from the same source. The viewport, that is the level of detail and the position of the displayed part of the map, travels in the query string, which keeps the server free of session state and makes every view bookmarkable.</p>
<p>I know that this is an unpopular statement nowadays where Angular, Vue, React and other JavaScript libraries are running riot but, in general, I don't advocate the idea of JavaScript user interfaces in Java applications. A component framework based on the Servlet API, such as PrimeFaces, would have been more appropriated and was the first candidate for this application. But I got stuck by the fact that, in Quarkus 4.0.1, every Servlet request over HTTP/3 fails with a <code>ClassCastException</code>. This is because the Vert.x adapter of the Quarkus Servlet implementation converts each connection to the class <code>ConnectionBase</code>, which the HTTP/3 connection of Vert.x does not extend. Hence, Qute and <code>htmx</code> in order to avoid the Servlet layer entirely.</p>
<p>The browser reports the protocol through the Resource Timing specification of the W3C. For every resource that a page loads, the browser records an object of the JavaScript interface <code>PerformanceResourceTiming</code>, which holds the timings of the resource and the protocol of the connection in the attribute <code>nextHopProtocol</code>, and the function <code>performance.getEntriesByName()</code> returns these objects for a given URL. A few lines of JavaScript read this attribute when each tile has loaded. They treat a resource decoded without any byte transferred as a response of the browser cache, and report the protocol as unknown when the browser withholds it:</p>
<pre><code class="language-js">function protocolOf(entry) {
  if (!entry) return 'cache';
  if (entry.transferSize === 0 &amp;&amp; entry.decodedBodySize &gt; 0) return 'cache';
  return entry.nextHopProtocol || 'unknown';
}
</code></pre>
<p>The browser exposes these details for a resource of another origin only when the response carries the header field <code>Timing-Allow-Origin</code> naming the page origin. <code>tile-service</code> therefore adds this field when the property <code>tiles.timing-allow-origin</code> is set, and the deployments of the map set it to the origin of <code>tile-map</code>. The benchmark leaves it unset, so that the header bytes that it measures remain unchanged.</p>
<p>A click on a tile adds a second HTTP/3 connection to the scene. The browser sends an <code>htmx</code> request to <code>tile-map</code>, which fetches the metadata of the tile from <code>tile-service</code> with the Quarkus REST client configured for HTTP/3. The returned fragment shows the metadata, the protocol that <code>tile-service</code> reports in its <code>X-Protocol</code> header field, and the duration of the request. This way the page documents a chain in which the browser talks to <code>tile-map</code> and <code>tile-map</code> talks to <code>tile-service</code>, both over HTTP/3. The client declares the operation with the return type <code>Uni</code> of Mutiny, the reactive programming library of Quarkus, in which a <code>Uni</code> represents a single result that arrives later. <code>tile-map</code> can therefore bound the request itself:</p>
<pre><code class="language-java">return tiles.meta(z, x, y)
  .ifNoItem().after(config.metaTimeout()).fail()
  .map(response -&gt; Templates.index$meta(...))
  .onFailure().recoverWithItem(failure -&gt;
    Templates.index$metaFailure(tile, reason(failure)));
</code></pre>
<p>The reader may be surprised to find the reactive style in this code, at a time when virtual threads, available since Java 21, allow a sequential implementation to wait for a response at almost no cost. This choice follows from the behavior of the HTTP/3 client, and not from a preference of style, as the explanation of the pipeline shows.</p>
<p>The pipeline above reads as follows. The call <code>ifNoItem().after(...).fail()</code> sets a time limit, given by the property <code>tiles.map.meta-timeout</code> and turns into a failure a response that has not arrived when it expires. This time limit is necessary, because the read timeout of the REST client never ends an HTTP/3 request and because a request whose end of stream is lost waits indefinitely. The reactive style is the appropriate choice here because it allows the request to be canceled. A sequential implementation, running on a virtual thread, would declare the operation with the blocking return type <code>RestResponse&lt;TileMeta&gt;</code>. With such a blocking client, the sequential style offers no direct means of canceling the request: the only limit the call accepts is the read timeout, which HTTP/3 ignores. An external mechanism, such as a <code>Future</code> awaited with a time limit, releases the waiting thread, while the request itself continues and its HTTP/3 stream remains open on the connection. The <code>Uni</code> returned by the reactive client, by contrast, can be canceled: when the time limit expires, Mutiny cancels the subscription and the client aborts the HTTP/3 stream. The reactive pipeline thus expresses the time limit, the cancellation of the request and the fallback in a single expression, and occupies no thread while the response is pending. </p>
<p>Browsers impose a condition of their own on HTTP/3. With the self-signed certificate of this project, Firefox uses HTTP/3 only after the preference <code>network.http.http3.disable_when_third_party_roots_found</code> is set to <code>false</code>. Chromium follows <code>Alt-Svc</code> only for certificates issued by an authority it knows, so that it needs command line flags that force QUIC for the two origins. With the Firefox preference, the page shows the discovery mechanism at work. The first load uses HTTP/2 for the page and for the 64 tiles, because the browser knows neither origin yet. The second load uses HTTP/3 for the page, the tiles and every update. The test <code>MapBrowserTest</code> drives Firefox through Playwright, a library that controls browsers from Java, and verifies against a <code>tile-service</code> container, in every build, that the second load and the following update travel over HTTP/3.</p>
<p>A second page of <code>tile-map</code> turns the map into a comparison lab. The Compose profile <code>lab</code> starts a second instance of <code>tile-service</code> on the port 9443, which advertises no HTTP/3 and therefore serves its tiles over HTTP/2 only. The second instance shares the network namespace of the first, so that the netem sidecar of the benchmark shapes the packets of both origins identically. The page fetches the same 64 tiles from both origins at the same time and shows, for each origin:</p>
<ul>
<li>the protocols used;</li>
<li>the time spent opening a new connection;</li>
<li>the total load time;</li>
<li>the waterfall in which every request appears as a bar between its start and its end.</li>
</ul>
<p>Each run adds a distinct query string to the tile addresses, so that the browser fetches every tile over the network instead of reusing its cache. Buttons apply the network profiles <code>lan</code>, <code>wan</code>, <code>lossy</code> and <code>degraded</code>. <code>tile-map</code> writes the requested profile into the directory that the sidecar watches and waits for its acknowledgement. Since the browser runs on the host, outside the emulated network, the sidecar applies the whole delay of a profile to the packets that the servers send, instead of dividing it between both sides as for the benchmark.</p>
<p>The waterfalls make the round trips visible: the 64 requests leave together, and their responses arrive in successive bands separated by one round trip as the congestion window grows. In the runs performed here, the HTTP/3 origin was slower than the HTTP/2 origin in every profile. A single run, however, reflects a single draw of the emulated losses and varies widely from one run to the next. Two limits of the measurement deserve mention. Firefox reports a fixed allowance of 300 bytes for the header fields of every response. With Docker, the browser opens its TCP connections to a local port proxy placed before the emulated network, whereas its QUIC packets cross that network, so a new HTTP/2 connection appears about one round trip faster than it is.</p>
<h2>Defects of quarkus-http3 4.0.1 and their workarounds</h2>
<p>The development of this project revealed three defects of the extension in its version 4.0.1, and the section that follows describes two limitations of the Vert.x HTTP/3 client on which the extension relies. Each defect was reproduced on a minimal application containing only <code>quarkus-rest</code>, <code>quarkus-http3</code> and a single resource.</p>
<h3>HTTP/2 responses lose their header fields</h3>
<p>With the extension enabled, HTTP/2 responses reached the client with a header block containing the status alone, and the static page never completed. The cause lies in the handler that the extension registers to advertise HTTP/3. For HTTP/2 requests, this handler calls <code>writeAltSvc()</code>, which in Vert.x 5.2.3 writes an <code>ALTSVC</code> frame through <code>writeCustomFrame()</code>, and that method sends the response head before writing the frame. Since the handler runs before the application, the head leaves the server with the default status and with an empty set of header fields, and every header field that the application sets afterward is lost. The defect is tracked as quarkusio/quarkus#58786.</p>
<p>The workaround consists of three steps:</p>
<ul>
<li>the configuration disables the handler of the extension with <code>quarkus.http3.alt-svc=false</code>;</li>
<li>the application advertises HTTP/3 with the <code>Alt-Svc</code> header field instead of the <code>ALTSVC</code> frame, which exists for HTTP/2 only;</li>
<li>the filter presented earlier adds that header field through <code>addHeadersEndHandler</code>, so that nothing is sent before the application has finished.</li>
</ul>
<p>A dedicated test sends an HTTP/2 request with the REST client and verifies that the full header set arrives, and this test fails as soon as the handler of the extension is enabled again.</p>
<h3>Disabling HTTP/3 prevents the application from starting</h3>
<p>Setting <code>quarkus.http3.enabled=false</code> causes the packaged application to fail at startup in production mode, with the message "HTTP/3 requires TLS but no HTTPS server was configured", even when TLS is configured. The build step that verifies TLS runs although the extension is disabled, and it inspects a flag that only the disabled component sets. The only effective way to run without HTTP/3 is therefore to remove the dependency, for instance in a dedicated Maven profile. This project keeps HTTP/3 enabled and is not affected.</p>
<h3>The request header limit applies to TCP only</h3>
<p>The property <code>quarkus.http.limits.max-header-size</code> limits the size of request headers on HTTP/1.1 connections, where an oversized request receives the status 431. Over HTTP/3, the same request was accepted with the status 200, because Vert.x leaves the HTTP/3 setting <code>MAX_FIELD_SECTION_SIZE</code> unlimited and Quarkus does not map its property onto it. The project applies the limit itself through an <code>HttpServerConfigCustomizer</code>, the extension point that Quarkus offers to adjust the Vert.x server configuration:</p>
<pre><code class="language-java">@Override
public void customizeHttpsServer(HttpServerConfig server,
    ServerSSLOptions sslOptions) {
  server.getQuicConfig().setClientAddressValidation(
    config.quic().addressValidation());
  Http3ServerConfig http3 = Objects.requireNonNullElseGet(
    server.getHttp3Config(), Http3ServerConfig::new);
  Http3Settings settings = Objects.requireNonNullElseGet(
    http3.getInitialSettings(), Http3Settings::new);
  server.setHttp3Config(http3.setInitialSettings(
    settings.setMaxFieldSectionSize(maxHeaderSize.asLongValue())));
}
</code></pre>
<p>With this customizer, the server refuses oversized requests over HTTP/3, but it does so by closing the whole QUIC connection, which also aborts every other request multiplexed on that connection, whereas HTTP/1.1 answers with the status 431. When the server closes the connection in this way, the Vert.x HTTP/3 client leaves the pending request incomplete indefinitely, and the REST client built on it disregards its read timeout, while curl reports the closure within a few milliseconds. The test of this behavior therefore uses the Vert.x client directly with a bounded wait.</p>
<p>The customizer also sets the QUIC address validation mode, whose effect on latency the benchmark examines in detail.</p>
<h2>Limitations of the Vert.x HTTP/3 client</h2>
<p>The HTTP client of Vert.x 5.2.3, on which the Quarkus REST client relies, shows two further limitations over HTTP/3. Both belong to Vert.x rather than to the extension, and reports to the Vert.x project describe them. </p>
<h3>Request timeouts</h3>
<p>The REST client passes its property <code>read-timeout</code> to the Vert.x option <code>RequestOptions.setTimeout</code>. This option bounds two waits: the establishment of the connection and the wait for data from the server once the request is sent. A Vert.x program independent of Quarkus has set the wait for data to 2 seconds and then measured the server behavior against three scenarios: a complete response, no response at all, and a response whose headers and first body bytes arrive before the server stops sending. The program waited at most 10 seconds for each request.</p>
<table>
<thead>
<tr>
<th>Server behaviour</th>
<th>HTTP/1.1</th>
<th>HTTP/2</th>
<th>HTTP/3</th>
</tr>
</thead>
<tbody><tr>
<td>Complete response</td>
<td>277 ms</td>
<td>62 ms</td>
<td>77 ms</td>
</tr>
<tr>
<td>No response</td>
<td>Timeout after 2 s</td>
<td>Timeout after 2 s</td>
<td>Pending after 10 s</td>
</tr>
<tr>
<td>Body interrupted</td>
<td>Pending after 10 s</td>
<td>Pending after 10 s</td>
<td>Pending after 10 s</td>
</tr>
</tbody></table>
<p>The table reveals two distinct behaviors. Over HTTP/3, the expiry of the timeout never ends a request. When the timeout expires, the client sends a STOP_SENDING frame, which asks the server to stop sending on that stream. But the client neither closes its own stream nor fails the request. Therefore, it waits for a reaction that a stalled or departed server never sends. A request pending on a QUIC connection that the server closes remains incomplete in the same way. Over every protocol, the client cancels the timeout as soon as the response headers arrive, so that a body interrupted after the headers remains unbounded, whereas the documentation of the option states that the timeout also applies to the response body.</p>
<p>The cancellation of the timeout at the arrival of the headers becomes critical in combination with a defect of <code>quiche</code>, which the subsection "HTTP/3 requests that never complete", later in this article, describes in detail: when the packet that carries the end of a stream is lost, <code>quiche</code> never retransmits it. The client then receives the complete body, but the end of the stream never arrives. An HTTP/3 request of the REST client that meets this defect therefore waits indefinitely, whatever its read timeout. In order to work around, the tests and <code>tile-map</code> consequently bound their HTTP/3 calls themselves, as follows:</p>
<ul>
<li>the metadata request of <code>tile-map</code> with a Mutiny time limit;</li>
<li>the page test of <code>tile-service</code> with a limit on the whole page;</li>
<li>the test of the request header limit with a bounded wait on the Vert.x client.</li>
</ul>
<h3>The receive buffer of QUIC sockets</h3>
<p>A QUIC endpoint receives all its connections through one UDP socket. When datagrams arrive faster than the application reads them and the receive buffer of the socket is full, the kernel discards each further datagram before QUIC sees it and increments its counter <code>UdpRcvbufErrors</code>, which the command <code>nstat</code> displays. On Linux, a socket that requests no particular size receives the buffer defined by the kernel parameter <code>net.core.rmem_default</code>, 208 kilobytes by default.</p>
<p>QUIC recovers a discarded datagram like any lost packet, at the cost of a probe timeout and of a reduced congestion window, except when the datagram carries the end of a stream, which the <code>quiche</code> defect never retransmits. The page test of <code>tile-service</code> met this case on the loopback interface, as the section "Testing over three protocols" below details: 64 requests in flight produce about 430 kilobytes of responses at once, and the kernel discarded up to 130 datagrams in a single run.</p>
<p>Vert.x 5.2.3 sizes the buffers of TCP sockets through <code>TcpConfig.setReceiveBufferSize</code>, whereas its QUIC configuration offers no equivalent setting, and the QUIC socket keeps the system default. An application can therefore enlarge this buffer only for the whole host, through <code>net.core.rmem_default</code>, a remedy whose effect this project has not measured. The QUIC implementation quic-go, for comparison, requests a receive buffer of 7 megabytes and warns at startup when the system grants less.</p>
<h2>Testing over three protocols</h2>
<p>The tests follow an integration first approach. The service tests start the complete application with <code>@QuarkusTest</code>, which also starts the HTTPS listener and the QUIC listener with an automatically generated certificate. REST Assured verifies the functional contract, the Problem Details responses and the <code>Alt-Svc</code> header over HTTP/1.1, since REST Assured speaks HTTP/1.1 only. The Quarkus REST client, configured once with <code>http2=true</code> and once with <code>http3=true</code>, verifies that the server observes the expected protocol through the <code>X-Protocol</code> header field, that the 64 tiles of a page arrive over a single HTTP/3 connection with 16 requests in flight, and that the header set of the <code>meta</code> operation survives QPACK compression intact.</p>
<p>With 64 requests in flight, the responses reach the client in a burst of about 430 kilobytes, which exceeds the default receive buffer of 208 kilobytes, of a Linux UDP socket. The kernel discards between 2 and 130 datagrams in each run as its counter <code>UdpRcvbufErrors</code> shows, even on the loopback interface. QUIC retransmits most of them, but a discarded end of stream triggers the defect described in the subsection "HTTP/3 requests that never complete", and the test then waits indefinitely, since the read timeout of the REST client never ends an HTTP/3 request. With 16 requests in flight, ten consecutive runs discarded no datagram. The subsection "The receive buffer of QUIC sockets", in the section "Limitations of the Vert.x HTTP/3 client" above, explains why the application cannot enlarge the receive buffer itself. The test additionally bounds the whole page to 30 seconds, so that a lost end of stream produces a failure instead of a blocked build.</p>
<p>The client tests start the container image of the service with Testcontainers. Testcontainers publishes TCP ports only, so the test binds the UDP port explicitly, on the same host port as the TCP port, because the HTTP/3 client connects to the port of the configured URL:</p>
<pre><code class="language-java">.withCreateContainerCmdModifier(cmd -&gt; {
  Ports bindings = cmd.getHostConfig().getPortBindings();
  bindings.bind(ExposedPort.tcp(8443),
    Ports.Binding.bindPort(quicPort));
  bindings.bind(ExposedPort.udp(8443),
    Ports.Binding.bindPort(quicPort));
})
</code></pre>
<p>The container also publishes its TCP port alone on a second host port, with no UDP binding. A dedicated HTTP/3 client, <code>TileH3DownClient</code>, targets this second port with a read timeout of 5000 ms. The test verifies that this client never falls back to the open TCP port: its request fails after about five seconds with the message "The timeout of 5000 ms has been exceeded when getting a connection".</p>
<h2>Deployment</h2>
<p>The container image exposes the port 8443 for both TCP and UDP, and Docker Compose publishes both:</p>
<pre><code class="language-yaml">ports:
  - "8443:8443/tcp"
  - "8443:8443/udp"
</code></pre>
<p>On Kubernetes, the extension <code>quarkus-minikube</code> generates the Deployment and the Service from the configuration of the application, and the build deploys them on Minikube. Serving HTTP/3 from a cluster requires adjustments to the generated manifest, concerning the keystore, the ports of the Service and the port that <code>Alt-Svc</code> announces, each of which this project has verified on Minikube 1.38 with Kubernetes 1.35.</p>
<p>The keystore reaches the pod through a Secret, which holds the PKCS#12 file and its password:</p>
<pre><code class="language-bash">kubectl create secret generic tile-tls \
  --from-file=tile-service.p12=benchmark/certs/tile-service.p12 \
  --from-literal=password=changeit
</code></pre>
<p>The configuration mounts this Secret at <code>/certs</code>, where the production profile expects the keystore, and maps the password onto the variable <code>TLS_KEYSTORE_PASSWORD</code>:</p>
<pre><code class="language-properties">quarkus.kubernetes.secret-volumes.certs.secret-name=tile-tls
quarkus.kubernetes.secret-volumes.certs.default-mode=0440
quarkus.kubernetes.security-context.fs-group=185
quarkus.kubernetes.mounts.certs.path=/certs
quarkus.kubernetes.mounts.certs.read-only=true
quarkus.kubernetes.env.mapping.tls-keystore-password.from-secret=tile-tls
quarkus.kubernetes.env.mapping.tls-keystore-password.with-key=password
</code></pre>
<p>Quarkus mounts Secret volumes with the mode 0600 by default, which reserves the file to the user <code>root</code>, whereas the Quarkus container image runs the application as the user 185. The mode 0440, combined with the group 185 that the property <code>fs-group</code> assigns to the volume, grants the application read access and keeps the keystore unreadable for other users of the container.</p>
<p>The Service must expose the port 8443 over both transport protocols. Kubernetes accepts a Service in which the same port number appears once for TCP and once for UDP, but the manifest generator of Quarkus 4.0.1 retains a single port for each container port number, so that the properties <code>quarkus.kubernetes.ports.*</code> cannot declare both. The project therefore supplies the ports of the Service in the file <code>src/main/kubernetes/minikube.yml</code>, which Quarkus merges into the generated manifest:</p>
<pre><code class="language-yaml">apiVersion: v1
kind: Service
metadata:
  name: tile-service
spec:
  ports:
    - name: http
      port: 80
      targetPort: 8080
      protocol: TCP
    - name: https
      port: 8443
      targetPort: 8443
      nodePort: 30443
      protocol: TCP
    - name: quic
      port: 8443
      targetPort: 8443
      nodePort: 30443
      protocol: UDP
</code></pre>
<p>The Service of type <code>NodePort</code> publishes HTTP/1.1 and HTTP/2 on the port 30443 of the node over TCP, and HTTP/3 on the same port over UDP. Keeping one port number for the three protocols matters, because the REST client configured for HTTP/3 connects to the UDP port of its URL, and because a browser reaches HTTP/3 through the port that the <code>Alt-Svc</code> header announces.</p>
<p>The port returned by the <code>Alt-Svc</code> header requires an adjustment as well. The filter of the application advertises by default the local port of the connection, which inside the pod is 8443, while clients reach the service on the port 30443 of the node. The property <code>tiles.alt-svc.port</code>, defined in the configuration interface <code>ProtocolConfig</code> of the module <code>tile-server-support</code>, replaces the local port with the published one in the <code>Alt-Svc</code> header field. The following line of the configuration sets it:</p>
<pre><code class="language-properties">quarkus.kubernetes.env.vars.tiles-alt-svc-port=30443
</code></pre>
<p>The extension turns this line into the environment variable <code>TILES_ALT_SVC_PORT</code> of the container, which Quarkus maps to the property <code>tiles.alt-svc.port</code>. Without this property, a client following the <code>Alt-Svc</code> header advertisement would send its QUIC packets to the port 8443 of the node, where no service listens.</p>
<p>The build produces the container image directly in the Docker daemon of Minikube and applies the manifest:</p>
<pre><code class="language-bash">eval $(minikube docker-env)
mvn install -DskipTests -pl tile-service -am \
  -Dquarkus.container-image.build=true \
  -Dquarkus.kubernetes.deploy=true
</code></pre>
<p>The requests below from the host verify the deployment. An HTTP/2 request receives the advertisement with the published port, an HTTP/3 request reaches the service over UDP, and curl, given a file in which it records alternative services, sends its first request over HTTP/2 and its second request over HTTP/3:</p>
<pre><code>$ curl -sk --http2 -D- -o /dev/null \
    https://$(minikube ip):30443/tiles/3/2/1/meta
HTTP/2 200
x-protocol: HTTP/2
alt-svc: h3=":30443"; ma=3600

$ curl -sk --http3-only -D- -o /dev/null \
    https://$(minikube ip):30443/tiles/3/2/1/meta
HTTP/3 200
x-protocol: HTTP/3

$ for i in 1 2; do curl -sk --alt-svc alt-svc.txt -o /dev/null \
    -w '%{http_version}\n' https://$(minikube ip):30443/tiles/3/2/1.png; done
2
3
</code></pre>
<p>On a cluster in a cloud environment, a Service of type <code>LoadBalancer</code> replaces the <code>NodePort</code>, and the load balancer must then forward UDP as well as TCP on the same port, a capability that varies between providers.</p>
<h2>Counting round trips</h2>
<p>The number of round trips that precede the RTT is, together with header compression, a subject that we're examining in detail here. This section first counts these round trips in theory for each protocol, then explains how the address validation of QUIC can add one more, and finally measures them on the demonstration application.</p>
<h3>The theoretical budget</h3>
<p>Before a client receives the first byte of a response, it exchanges a number of messages with the server, and each exchange costs one round trip time. Over TCP and TLS 1.3, the TCP handshake costs one round trip, the TLS handshake costs a second round trip, and the request and its response cost a third. QUIC combines the transport handshake and the TLS handshake, so a new HTTP/3 connection costs one round trip for the handshake and a second one for the request. With 0-RTT, a client that resumes a previous session sends its request in its first packet, and the response arrives after a single round trip.</p>
<p><img src="https://raw.githubusercontent.com/nicolasduminil/http3-quarkus/master/diagrams/05-handshake-rtt.png" alt="Round trips of a new TCP and TLS 1.3 connection compared with QUIC" /></p>
<h3>Address validation and the Retry packet</h3>
<p>A QUIC server may answer the first packet of a client with a Retry packet that carries a token. The client must then repeat its first packet with this token, which proves that it receives traffic at its source address. This mechanism protects the server against attackers who forge the source address of their packets, either to make the server send its larger handshake responses to a victim, an attack called amplification, or to exhaust the server with connection attempts. The protection costs one additional round trip for every new connection.</p>
<p>Vert.x configures QUIC servers with the address validation mode <code>BASIC</code> by default, which sends a Retry packet to every new client and uses tokens without cryptographic protection. The mode <code>NONE</code> disables the Retry packet, and the mode <code>CRYPTO</code> signs the tokens with a key that the application provides. Quarkus exposes none of these modes, and this project makes them configurable through the property <code>tiles.quic.address-validation</code> and the customizer shown earlier. <code>qlog</code> is the event log format that the QUIC working group of the IETF is standardizing, in which an endpoint records every packet that it sends or receives, together with the frames that the packet contains. The <code>qlog</code> traces recorded by <code>h2load</code>, the load generator presented with the benchmark, confirm the mechanism: with the mode <code>BASIC</code>, the client receives exactly one Retry packet per connection, and with the mode <code>NONE</code> it receives none.</p>
<h3>Measuring the round trips</h3>
<p><code>curl</code> reports several timestamps for each request. For TCP, <code>time_connect</code> marks the completion of the TCP handshake and <code>time_appconnect</code> marks the completion of the TLS handshake. For HTTP/3, <code>curl</code> built with ngtcp2 records <code>time_connect</code> when the first packet of the server arrives and <code>time_appconnect</code> when the QUIC handshake completes. In both cases, <code>time_starttransfer</code> marks the arrival of the first byte of the response. Dividing these times by the round trip time configured in the network emulation expresses them in round trips.</p>
<p>The benchmark measures each combination of network profile, protocol and connection mode with 50 requests, each of which opens a new connection. Three connection modes are measured:</p>
<ul>
<li>a cold connection starts without any prior state;</li>
<li>a resumed connection presents the TLS session ticket obtained by a previous connection;</li>
<li>an early data connection presents the same ticket and additionally asks <code>curl</code> to send its request as 0-RTT data.</li>
</ul>
<p><code>curl</code> stops any request after 20 seconds, and such a request counts as a failed sample, excluded from the medians.</p>
<p>On the emulated wide area network, with a round trip time of 50 milliseconds, cold connections give the following medians:</p>
<table>
<thead>
<tr>
<th>Connection</th>
<th>Encryption established</th>
<th>First response byte</th>
</tr>
</thead>
<tbody><tr>
<td>HTTP/1.1, TCP and TLS 1.3</td>
<td>108.1 ms (2.16 RTT)</td>
<td>159.0 ms (3.18 RTT)</td>
</tr>
<tr>
<td>HTTP/2, TCP and TLS 1.3</td>
<td>108.1 ms (2.16 RTT)</td>
<td>159.3 ms (3.19 RTT)</td>
</tr>
<tr>
<td>HTTP/3, address validation <code>BASIC</code></td>
<td>106.6 ms (2.13 RTT)</td>
<td>159.0 ms (3.18 RTT)</td>
</tr>
<tr>
<td>HTTP/3, address validation <code>NONE</code></td>
<td>56.7 ms (1.13 RTT)</td>
<td>109.0 ms (2.18 RTT)</td>
</tr>
</tbody></table>
<p>The measured time in the table above are slightly longer that they should. The first response byte of HTTP/2, for example, arrives after 159.3 milliseconds, while it should have come after 150 milliseconds for three round trips of 50 ms. The additional time of 9.3 milliseconds represent the time that the client and the server spend computing, such as the cryptographic operations of the handshake and the handling of the request, and not time spent on the network. With the default configuration of Quarkus, the Retry packet consumes the round trip that QUIC saves, and a new HTTP/3 connection costs exactly as many round trips as a new HTTP/2 connection. With the mode <code>NONE</code>, HTTP/3 reaches the budget that its design promises and delivers the first response byte one round trip earlier, 50 milliseconds on this network.</p>
<p>The time to the first response byte of cold connections across all profiles confirms this result:</p>
<table>
<thead>
<tr>
<th>Connection</th>
<th><code>lan</code></th>
<th><code>wan</code></th>
<th><code>lossy</code></th>
<th><code>degraded</code></th>
</tr>
</thead>
<tbody><tr>
<td>HTTP/1.1</td>
<td>3.6 ms</td>
<td>159.0 ms (3.18 RTT)</td>
<td>168.7 ms (3.37 RTT)</td>
<td>162.3 ms (3.25 RTT)</td>
</tr>
<tr>
<td>HTTP/2</td>
<td>3.2 ms</td>
<td>159.3 ms (3.19 RTT)</td>
<td>164.0 ms (3.28 RTT)</td>
<td>162.1 ms (3.24 RTT)</td>
</tr>
<tr>
<td>HTTP/3, <code>BASIC</code></td>
<td>3.9 ms</td>
<td>159.0 ms (3.18 RTT)</td>
<td>162.8 ms (3.26 RTT)</td>
<td>161.3 ms (3.23 RTT)</td>
</tr>
<tr>
<td>HTTP/3, <code>NONE</code></td>
<td>3.7 ms</td>
<td>109.0 ms (2.18 RTT)</td>
<td>108.8 ms (2.18 RTT)</td>
<td>108.7 ms (2.17 RTT)</td>
</tr>
</tbody></table>
<p>The report of the benchmark draws these medians as a chart, in which each bar splits the time to the first response byte into three parts: the connection, up to <code>time_connect</code>, the TLS or QUIC handshake, up to <code>time_appconnect</code>, and the request, up to the first response byte. With <code>BASIC</code>, the first packet of the server is the Retry packet, so the connection part already lasts one round trip and the handshake needs a second one. With <code>NONE</code>, the first packets of the server already carry the handshake, which completes almost immediately after them.</p>
<p><img src="https://raw.githubusercontent.com/nicolasduminil/http3-quarkus/master/benchmark/results/rtt.png" alt="Time to the first response byte of cold connections, by profile and protocol" /></p>
<p>On the local profile, where a round trip costs about 0.1 millisecond, the four configurations remain within one millisecond of each other, and the processing time dominates. On the three emulated networks, the medians stay at three round trips for TCP and for HTTP/3 with <code>BASIC</code>, and at two round trips for HTTP/3 with <code>NONE</code>, because most handshakes of a sample of 50 encounter no loss. Losses appear in the 95th percentile. With 5 percent loss, it reaches 1638 milliseconds for HTTP/1.1, 1358 milliseconds for HTTP/2 and 1414 milliseconds for HTTP/3 with <code>BASIC</code>, which is consistent with the initial retransmission timeout of one second. HTTP/3 with <code>NONE</code> reaches 351 milliseconds, and the present measurements leave the cause of this difference open. In addition, up to four HTTP/3 requests out of 50 exceeded the time limit in the groups measured with loss, 21 requests out of 600 in total, a consequence of the defect described in the subsection "HTTP/3 requests that never complete" of the benchmark results.</p>
<p>Resumed connections give the same medians as cold connections for every protocol, within one millisecond on the wide area network and within six milliseconds on the networks with loss. For TCP this result follows from TLS 1.3 itself, whose session resumption saves the certificate exchange and its verification but keeps the same number of round trips. The chart of resumed connections therefore reproduces the chart of cold connections:</p>
<p><img src="https://raw.githubusercontent.com/nicolasduminil/http3-quarkus/master/benchmark/results/rtt-resumed.png" alt="Time to the first response byte of resumed connections, by profile and protocol" /></p>
<p>Early data connections give the same medians as well, within the same margins. <code>curl</code> reports <code>tls_earlydata</code> equal to zero for every connection, consistent with the fact that Vert.x never enables early data on its QUIC server, whatever the configuration. The request therefore waits for the end of the handshake, as in a cold connection, and 0-RTT stays unused:</p>
<p><img src="https://raw.githubusercontent.com/nicolasduminil/http3-quarkus/master/benchmark/results/rtt-earlydata.png" alt="Time to the first response byte of early data connections, by profile and protocol" /></p>
<h2>The benchmark</h2>
<p>The benchmark compares HTTP/1.1, HTTP/2 and HTTP/3 on the demonstration application under network conditions that range from a local network to a distant network that loses packets. This section describes the containers that take part in the measurements, the way they emulate a wide area network, and the network profiles and scenarios measured, before it presents the results, including the requests that never complete and the effect of header compression.</p>
<h3>Topology</h3>
<p>The benchmark runs in Docker Compose. The service container receives a sidecar container that shares its network namespace, and a benchmark container hosts <code>h2load</code> and <code>curl</code>, both built from source with HTTP/3 support. <code>curl</code> 8.23.0 and <code>h2load</code> 1.71.0 implement QUIC with the <code>ngtcp2</code> 1.26.0 library and HTTP/3 with the <code>nghttp3</code> 1.19.0 library, and both rely on OpenSSL 3.6.5 for the TLS 1.3 handshake and the packet protection. Both sides of the connection pass through an emulated wide area network, which the next section describes.</p>
<p><img src="https://raw.githubusercontent.com/nicolasduminil/http3-quarkus/master/diagrams/04-benchmark-topology.png" alt="Topology of the benchmark" /></p>
<h3>Emulating the wide area network</h3>
<p>The containers of Docker Compose communicate through a virtual bridge inside a single machine, where a round trip lasts less than a tenth of a millisecond and no packet is lost. The benchmark therefore degrades this path artificially with the traffic control facility of the Linux kernel. Every network interface of Linux owns a queueing discipline, abbreviated <code>qdisc</code>, which decides when each outgoing packet leaves the interface and whether it leaves at all. The command <code>tc</code> replaces this discipline, and the discipline <code>netem</code>, for network emulator, holds each outgoing packet for a configured delay and discards a configured proportion of the packets. A <code>qdisc</code> governs the outgoing packets of its interface only, so emulating both directions of a connection requires one discipline on each side.</p>
<p>The client side is the interface <code>eth0</code> of the benchmark container, which carries the requests and the acknowledgements that <code>h2load</code> and <code>curl</code> send. The server side is the interface <code>eth0</code> of <code>tile-service</code>, which carries the responses. Changing a <code>qdisc</code> requires the Linux capability <code>NET_ADMIN</code>, and the image of <code>tile-service</code> contains neither the <code>tc</code> command nor that capability. A sidecar container, built from the benchmark image, therefore joins the network namespace of <code>tile-service</code> through the Compose setting <code>network_mode: "service:tile-service"</code>, and receives the capability <code>NET_ADMIN</code>. The sidecar sees the same interface as the service and shapes its outgoing packets, while the application container keeps its minimal image and runs without any additional privilege.</p>
<pre><code class="language-yaml">netem:
  image: simplex-software/tile-bench:1.0.1
  network_mode: "service:tile-service"
  cap_add:
    - NET_ADMIN
  command: ["/benchmark/netem.sh", "--watch"]
</code></pre>
<p>The script <code>benchmark/netem.sh</code> defines the four profiles and applies them on each side with a single command:</p>
<pre><code class="language-bash">tc qdisc replace dev eth0 root netem \
  delay "${delay}ms" loss "${loss}%" limit 10000
</code></pre>
<table>
<thead>
<tr>
<th>Profile</th>
<th>Round trip time</th>
<th>Delay on each side</th>
<th>Loss on each side</th>
<th>Expected loss on a round trip</th>
</tr>
</thead>
<tbody><tr>
<td><code>lan</code></td>
<td>unchanged</td>
<td>0 ms</td>
<td>0 %</td>
<td>0 %</td>
</tr>
<tr>
<td><code>wan</code></td>
<td>50 ms</td>
<td>25 ms</td>
<td>0 %</td>
<td>0 %</td>
</tr>
<tr>
<td><code>lossy</code></td>
<td>50 ms</td>
<td>25 ms</td>
<td>1 %</td>
<td>1.99 %</td>
</tr>
<tr>
<td><code>degraded</code></td>
<td>50 ms</td>
<td>25 ms</td>
<td>5 %</td>
<td>9.75 %</td>
</tr>
</tbody></table>
<p>Each side adds half of the round trip time, so that a request and its response together accumulate the delay of the profile. Each side discards the full loss rate of the profile, so that each direction loses packets at that rate independently of the other. Therefore, a request and its response, carried by one packet each, both arrive with the probability <code>(1 − p)²</code>, where <code>p</code> is the loss rate of the profile. An exchange fails with the probability given in the last column. The emulation operates below the transport layer, so it treats the TCP segments of HTTP/1.1 and HTTP/2 and the UDP datagrams of HTTP/3 identically, including the handshake packets, the acknowledgements and the Retry packets.</p>
<p>The parameter <code>limit</code> sets the number of packets that the discipline may hold at once. <code>netem</code> keeps every delayed packet in its queue, and its default limit of 1000 packets, held for 25 milliseconds, would overflow as soon as a sender exceeded 40000 packets per second. The overflow would discard packets beyond the configured rate, so the benchmark raises the limit to 10000 packets, and the configured loss rate remains the only source of loss.</p>
<p>The two sides change their profile together through a shared directory, <code>benchmark/results/.netem</code>, mounted in both containers. Before measuring a profile, the scripts <code>run.sh</code> and <code>rtt.sh</code> apply it to the client side, write its name into the file <code>request</code> of that directory, and wait for the file <code>applied</code> to contain the same name. The sidecar checks the file <code>request</code> every 200 milliseconds, applies the requested profile to the server side, and writes its name into the file <code>applied</code>. If the acknowledgement takes more than ten seconds, the script stops with an error, so that no measurement ever runs with a single shaped side. When a script ends, it restores the profile <code>lan</code> on both sides. <code>tile-map</code> uses the same exchange for the buttons of its comparison lab, with the variable <code>NETEM_SIDES=1</code> that places the whole delay on the server side, because the browser runs on the host, outside the emulated network.</p>
<p>A measurement independent of the benchmark tools verifies the emulation. A container providing <code>ping</code> joined the network namespace of the benchmark container and sent 3000 echo requests of 1200 bytes to <code>tile-service</code> for each profile:</p>
<table>
<thead>
<tr>
<th>Profile</th>
<th>Average round trip</th>
<th>Echo requests lost</th>
<th>Observed loss</th>
<th>Expected loss</th>
</tr>
</thead>
<tbody><tr>
<td><code>lan</code></td>
<td>0.07 ms</td>
<td>0 out of 3000</td>
<td>0 %</td>
<td>0 %</td>
</tr>
<tr>
<td><code>wan</code></td>
<td>50.1 ms</td>
<td>0 out of 3000</td>
<td>0 %</td>
<td>0 %</td>
</tr>
<tr>
<td><code>lossy</code></td>
<td>50.1 ms</td>
<td>65 out of 3000</td>
<td>2.2 %</td>
<td>1.99 %</td>
</tr>
<tr>
<td><code>degraded</code></td>
<td>50.1 ms</td>
<td>265 out of 3000</td>
<td>8.8 %</td>
<td>9.75 %</td>
</tr>
</tbody></table>
<p>The observed losses lie within the statistical variation of a sample of 3000 exchanges, and the round trip exceeds the configured 50 milliseconds by about 0.1 millisecond, the time spent crossing the bridge. The QUIC stack of <code>h2load</code> reaches the same conclusion: the median of the smoothed round trip time, the estimate that QUIC maintains from its acknowledgements and that <code>h2load</code> reports for each HTTP/3 run, averages 51.5 milliseconds over the runs of the profile <code>wan</code>.</p>
<p>This emulation reproduces a long network path with random losses, whose characteristics define the scope of the results:</p>
<ul>
<li>constant delay: every packet waits exactly the configured delay, so packets arrive in the order in which they were sent;</li>
<li>independent losses: each packet is lost independently of the others, at the configured rate;</li>
<li>unlimited bandwidth: congestion control reacts to the emulated losses alone;</li>
<li>symmetric directions: both directions have the same delay, the same loss rate and the same capacity.</li>
</ul>
<p>The results of this benchmark therefore characterize the protocols on a distant path with random and independent losses. In a mobile or congested link, the delay may vary, the losses may come in bursts and the bandwidth may be limited and often lower upstream than downstream. Such case calls for a richer model, which <code>netem</code> supports, for example with its Gilbert-Elliott loss model, named <code>loss gemodel</code>, dedicated to losses in bursts.</p>
<p>The emulation can be inspected while it runs. The sidecar keeps the profile last applied, and the statistics of its discipline count the packets that it has sent and discarded:</p>
<pre><code class="language-bash">docker compose up -d --wait tile-service netem
docker compose exec netem tc -s qdisc show dev eth0
</code></pre>
<h3>Profiles and scenarios</h3>
<p>The following network profiles are measured:</p>
<ul>
<li><code>lan</code> adds no delay and no loss; </li>
<li><code>wan</code> adds a round trip time of 50 milliseconds;</li>
<li><code>lossy</code> adds the same delay and a loss rate of 1 percent;</li>
<li><code>degraded</code> adds the same delay and a loss rate of 5 percent.</li>
</ul>
<p>The following scenarios are measured with <code>h2load</code>:</p>
<ul>
<li>the <em>page load</em> scenario fetches the 64 tiles of one view, with six connections for HTTP/1.1, as a browser would open, and with one connection carrying 64 concurrent streams for HTTP/2 and HTTP/3;</li>
<li>the <em>throughput</em> scenario sends 10000 requests from 32 clients;</li>
<li>the <em>header</em> scenario requests the <code>meta</code> operation 1000 times, sequentially and then with 64 concurrent streams, in four variants: HTTP/1.1 as the uncompressed baseline, HTTP/2 with the default HPACK dynamic table, HTTP/2 with a dynamic table of size zero, and HTTP/3.</li>
</ul>
<p>Before each profile, every protocol receives 2000 warm up requests, so that the measurements reflect a server whose code the Java virtual machine has already compiled.</p>
<h3>Results</h3>
<p>The <em>page load</em> scenario runs ten times for each profile and protocol. The following table gives the median duration of one page load over the runs in which every request succeeded, and states how many of the ten runs contained a failed request. The address validation mode <code>NONE</code> was measured for HTTP/3 only, since it concerns QUIC alone.</p>
<table>
<thead>
<tr>
<th>Profile</th>
<th>HTTP/1.1</th>
<th>HTTP/2</th>
<th>HTTP/3, <code>BASIC</code></th>
<th>HTTP/3, <code>NONE</code></th>
</tr>
</thead>
<tbody><tr>
<td><code>wan</code></td>
<td>717.6 ms</td>
<td>408.9 ms</td>
<td>418.0 ms</td>
<td>371.9 ms</td>
</tr>
<tr>
<td><code>lossy</code></td>
<td>1022.5 ms</td>
<td>486.8 ms</td>
<td>826.7 ms, 2 runs failed</td>
<td>803.6 ms</td>
</tr>
<tr>
<td><code>degraded</code></td>
<td>2081.8 ms</td>
<td>1255.8 ms</td>
<td>3490.5 ms, 3 runs failed</td>
<td>3587.4 ms, 1 run failed</td>
</tr>
</tbody></table>
<p>On the wide area network, HTTP/1.1 needs about 718 milliseconds, because its six connections each transmit about eleven requests one after the other, and each request costs one round trip. HTTP/2 and HTTP/3 multiplex the 64 requests on a single connection and shorten this duration by about 40 percent. HTTP/3 with <code>BASIC</code> and HTTP/2 differ by 9 milliseconds, while HTTP/3 with <code>NONE</code> saves 46 milliseconds, close to the round trip of the Retry packet that this mode removes.</p>
<p>With packet loss, HTTP/3 performs worse than HTTP/2, even in the runs without failed requests, although QUIC removes the head of line blocking that penalizes HTTP/2 over TCP. Two properties of the implementation can contribute to this result. HTTP/3 transmits the header block of a response in a HEADERS frame and its body in DATA frames, both on the stream of the request. The traces show that the server sends each response in three separate packets, one carrying the HEADERS frame, one carrying the DATA frame and one carrying the end of the stream. Accordingly, each response is exposed to three potential losses where TCP coalesces the same bytes into fewer segments. The loss recovery and the congestion control of <code>quiche</code> also differ from those of the Linux TCP stack. The present measurements leave the respective weight of these two contributions open. Every failed run, in turn, has a single cause, presented in the subsection "HTTP/3 requests that never complete" below.</p>
<p>On the local profile, the page load times depend on the state of the Java virtual machine more than on the protocol. In the full benchmark run, which warms up and measures HTTP/1.1, HTTP/2 and HTTP/3 in turn, the medians are 36.2 milliseconds for HTTP/1.1, 33.2 for HTTP/2 and 36.9 for HTTP/3 with <code>BASIC</code>. In a run that warms up and measures HTTP/3 alone, the median falls to 12.0 milliseconds with <code>NONE</code> and to 12.6 milliseconds with <code>BASIC</code>. The two address validation modes thus give the same result, as expected when a round trip costs 0.1 millisecond, and the local profile serves only to verify that the service itself adds no significant latency.</p>
<p>The <em>throughput</em> scenario sends 10000 requests from 32 clients, with ten concurrent streams per client for HTTP/2 and HTTP/3, three times for each profile and protocol. The table gives the median rate over the runs without failed requests.</p>
<table>
<thead>
<tr>
<th>Profile</th>
<th>HTTP/1.1</th>
<th>HTTP/2</th>
<th>HTTP/3, <code>BASIC</code></th>
</tr>
</thead>
<tbody><tr>
<td><code>lan</code></td>
<td>5068 req/s</td>
<td>8318 req/s</td>
<td>10381 req/s, 1 run out of 3 without failure</td>
</tr>
<tr>
<td><code>wan</code></td>
<td>618 req/s</td>
<td>5454 req/s</td>
<td>5304 req/s</td>
</tr>
<tr>
<td><code>lossy</code></td>
<td>435 req/s</td>
<td>1527 req/s</td>
<td>every run failed</td>
</tr>
<tr>
<td><code>degraded</code></td>
<td>234 req/s</td>
<td>600 req/s</td>
<td>every run failed</td>
</tr>
</tbody></table>
<p>On the wide area network, HTTP/2 and HTTP/3 deliver about nine times the rate of HTTP/1.1, because each client keeps ten requests in flight instead of one. Every HTTP/3 run with loss lost requests, between 72 and 102 out of 10000 with 1 percent loss and between 9 and 33 with 5 percent loss. Two of the three runs on the local profile lost 3 and 9 requests. HTTP/1.1 and HTTP/2 completed every request of every run.</p>
<h3>HTTP/3 requests that never complete</h3>
<p>The <code>qlog</code> traces recorded by <code>h2load</code> and <code>curl</code> show the same sequence for every request that failed. The client receives the complete response body, and the packet that follows the body is lost. When a sender receives no acknowledgement within a delay that QUIC derives from the measured round trip time, called the probe timeout, it sends a probe packet to provoke one. The server then sends only probes containing a PING frame, which requests an acknowledgement and carries no data, and the stream never ends, so that the request remains pending until the client gives up.</p>
<p><img src="https://raw.githubusercontent.com/nicolasduminil/http3-quarkus/master/diagrams/07-lost-fin.png" alt="A lost end of stream that quiche never retransmits" /></p>
<p>The cause lies in <code>quiche</code>, at the revision <code>be47c50</code> that Netty 4.2.20 4.2.21 still bundle. QUIC carries the bytes of each stream in STREAM frames, each of which states the offset of its bytes in the stream. Vert.x ends each response with a separate STREAM frame that carries no data and only the FIN flag, which marks the end of the stream. The defect unfolds in three steps.</p>
<ol>
<li>The method <code>SendBuf::is_complete()</code> of <code>quiche</code> considers the sending side of a stream complete when the peer has acknowledged every byte from offset zero to the final offset. A STREAM frame of length zero covers no byte, so the acknowledgement of the DATA frame alone satisfies this condition.</li>
<li>When this acknowledgement arrives, <code>quiche</code> finds the stream complete in both directions and releases it.</li>
<li>When <code>quiche</code> later declares the packet carrying the FIN lost, it finds no stream for the lost frame and discards the frame instead of retransmitting it.</li>
</ol>
<p>Lost packets that carry data are retransmitted correctly, because their acknowledgement is still missing when the loss is detected. The defect therefore affects only the end of stream, and only when its packet is lost after the data packets have been acknowledged. A single connection that carries many requests, such as the sequential header scenario or a throughput client, eventually meets this case, and the connection then stops making progress for that stream. The local profile loses no packet by emulation, and the two failed throughput runs there are consistent with the datagrams that the kernel discards when the QUICK socket receive buffer is full. </p>
<p>The <code>quiche</code> project corrected the defect in the commits <code>af8788e</code>, which tracks the acknowledgement of the FIN separately, and <code>1128f94</code>, which keeps a pending FIN schedulable after the data has been acknowledged. Both commits are more recent than the revision that Netty bundles, and a report to the Netty project requests the update of the bundled revision. Until Netty updates quiche and Vert.x and Quarkus adopt that release, HTTP/3 in Quarkus 4.0.1 should be considered unreliable on networks that lose packets, a condition common on wireless and mobile networks.</p>
<h3>Header compression results</h3>
<p>The header scenario gives the following medians over three runs. Header compression depends on the sequence of header fields and not on the network, and every variant transmits the same number of header bytes on the four profiles and in both the sequential and the concurrent form, with one exception discussed below.</p>
<table>
<thead>
<tr>
<th>Variant</th>
<th>Response header bytes</th>
<th>Savings</th>
</tr>
</thead>
<tbody><tr>
<td>HTTP/1.1</td>
<td>789000</td>
<td>0 %</td>
</tr>
<tr>
<td>HTTP/2, HPACK dynamic table</td>
<td>16697</td>
<td>97.9 %</td>
</tr>
<tr>
<td>HTTP/2, HPACK static table only</td>
<td>721001</td>
<td>9.5 %</td>
</tr>
<tr>
<td>HTTP/3, QPACK static table only</td>
<td>471000</td>
<td>38.9 %</td>
</tr>
</tbody></table>
<p>HPACK with its dynamic table reduces the repeated header set of the <code>meta</code> operation to a few bytes per response, because every field becomes a one byte index after its first occurrence. When the client limits the HPACK dynamic table to zero, the savings fall to about 10 percent, which comes from the static table alone, since Netty applies Huffman coding only to long strings. QPACK as configured by Vert.x saves about 39 percent: the static table contributes the same kind of reduction as for HPACK, and the systematic Huffman coding of the literal values contributes the rest. The comparison shows that the gap between HTTP/2 and HTTP/3 in this measurement reflects an implementation choice of Vert.x rather than a property of QPACK, since RFC 9204 provides a dynamic table equivalent to that of HPACK, and an encoder using it can be expected to reach comparable savings on such repetitive header sets.</p>
<p>The exception concerns the sequential form of HTTP/3 on the profiles with loss. In this form, the scenario sends its 1000 requests one after the other on a single connection, and each response carries 471 bytes of header fields, so a complete run transmits 471000 bytes. With 1 percent loss, the median run transmitted only 9420 bytes, that is the header fields of about 20 responses. With 5 percent loss only 4239 bytes, that is about 9 responses. In both cases, the run stopped at the first response whose end of stream was lost, as described in the subsection "HTTP/3 requests that never complete", and the connection carried no further request. The responses received before that point keep the compression ratio of 38.9 percent.</p>
<h2>Running the project</h2>
<p>This section gathers the commands that build, test and run every part of the project, from the unit tests to the complete benchmark. The project is obtained from its GitHub repository, and all commands run from its root directory:</p>
<pre><code class="language-bash">git clone https://github.com/nicolasduminil/http3-quarkus.git
cd http3-quarkus
</code></pre>
<h3>Prerequisites</h3>
<p>The project requires Java 25, Maven 3.9 and Docker with Docker Compose. The integration tests start containers through Testcontainers, so the Docker daemon must be running before the build. The browser tests of <code>tile-map</code> drive Firefox through Playwright, which downloads its browsers into <code>~/.cache/ms-playwright</code> on its first run. On Linux, Firefox additionally needs system libraries, which a single command installs:</p>
<pre><code class="language-bash">sudo npx playwright@1.65.1 install-deps firefox
</code></pre>
<p>A browser and curl complete the list for the manual steps. The curl of most Linux distributions supports HTTP/1.1 and HTTP/2 only, and the benchmark image of the project provides a curl built with HTTP/3 support. pandoc displays the summary of the benchmark in the terminal.</p>
<h3>Building and testing</h3>
<p>A single Maven command compiles the six modules, builds the container images <code>simplex-software/tile-service:1.0.1</code> and <code>simplex-software/tile-map:1.0.1</code>, and runs every test:</p>
<pre><code class="language-bash">mvn install -Dquarkus.container-image.build=true
</code></pre>
<p>Maven builds the modules in dependency order, so the image of <code>tile-service</code> exists before the tests of <code>tile-client</code> and <code>tile-map</code> start it as a container. The tests are organized by module as follows.</p>
<table>
<thead>
<tr>
<th>Module</th>
<th>Test classes</th>
<th>Verified behaviour</th>
</tr>
</thead>
<tbody><tr>
<td><code>tile-service</code></td>
<td><code>TileResourceTest</code></td>
<td>Functional contract over HTTP/1.1, <code>Alt-Svc</code> header, Problem Details responses</td>
</tr>
<tr>
<td><code>tile-service</code></td>
<td><code>TileHttp2Test</code>, <code>TileHttp3Test</code></td>
<td>Protocol observed by the server, 64 tiles over a single QUIC connection, header set intact after QPACK</td>
</tr>
<tr>
<td><code>tile-service</code></td>
<td><code>RestrictedServiceTest</code>, <code>Http3ServerCustomizerTest</code>, <code>DeploymentOverridesTest</code></td>
<td>Request header limit on both transports, address validation mode, advertised port and <code>Timing-Allow-Origin</code></td>
</tr>
<tr>
<td><code>tile-client</code></td>
<td><code>TileClientTest</code>, <code>TileClientMainTest</code></td>
<td>Each client speaks its protocol against the container, the HTTP/3 client never falls back to TCP, invalid arguments</td>
</tr>
<tr>
<td><code>tile-map</code></td>
<td><code>ViewportTest</code>, <code>MapPageTest</code>, <code>LabPageTest</code></td>
<td>Navigation arithmetic, rendering of the page and of its fragments, error responses</td>
</tr>
<tr>
<td><code>tile-map</code></td>
<td><code>MapHttp3Test</code>, <code>MapMetaTest</code>, <code>UnreachableServiceTest</code></td>
<td>Page served over HTTP/3, metadata fetched from the container over HTTP/3, time limit with an unreachable service</td>
</tr>
<tr>
<td><code>tile-map</code></td>
<td><code>LabNetworkTest</code>, <code>LabEnabledTest</code></td>
<td>Exchange of network profiles with the sidecar, including the time limit when the sidecar never answers</td>
</tr>
<tr>
<td><code>tile-map</code></td>
<td><code>MapBrowserTest</code>, <code>LabBrowserTest</code></td>
<td>Firefox discovers HTTP/3 through <code>Alt-Svc</code>, and each panel of the lab loads its tiles over its own protocol</td>
</tr>
</tbody></table>
<p>Once the images exist, the tests of one module, or a single test class, run without rebuilding the others:</p>
<pre><code class="language-bash">mvn test -pl tile-service
mvn test -pl tile-map -Dtest=MapBrowserTest
</code></pre>
<p>The continuous integration pipeline in <code>.circleci/config.yml</code> runs the same steps on a virtual machine that provides a Docker daemon: it builds the images without tests, installs the Firefox libraries, runs <code>mvn verify</code>, and checks that the report generator of the benchmark compiles and runs.</p>
<h3>Running the service and the client</h3>
<p>In development mode, Quarkus generates a self-signed certificate and serves the service on the port 8443:</p>
<pre><code class="language-bash">mvn -pl tile-service quarkus:dev
</code></pre>
<p>The packaged image runs with the certificate of the project, which a script generates once. Its subject alternative names cover <code>localhost</code>, <code>127.0.0.1</code> and the service name <code>tile-service</code>:</p>
<pre><code class="language-bash">./benchmark/certs.sh
docker compose up -d --wait tile-service
</code></pre>
<p>Two requests from the benchmark image show the same resource over HTTP/2 and over HTTP/3. The <code>x-protocol</code> header field of each response reports the protocol that the server observed, and the HTTP/2 response carries the <code>Alt-Svc</code> advertisement:</p>
<pre><code class="language-bash">docker compose run --rm bench curl -sk --http2 -D - -o /dev/null \
  https://tile-service:8443/tiles/3/2/1.png
docker compose run --rm bench curl -sk --http3-only -D - -o /dev/null \
  https://tile-service:8443/tiles/3/2/1.png
</code></pre>
<p>The command line client fetches the 64 tiles of one view with the protocol given as its argument, <code>h1</code>, <code>h2</code> or <code>h3</code>, and an optional origin given as three further arguments <code>z x y</code>:</p>
<pre><code>$ java -Dtiles.url=https://localhost:8443 \
    -jar tile-client/target/quarkus-app/quarkus-run.jar h3
protocol requested : h3
protocol observed  : HTTP/3
tiles fetched      : 64
first request      : 432 ms (connection setup included)
median of others   : 119 ms
total wall time    : 580 ms
total bytes        : 432863
</code></pre>
<p>The first request includes the opening of the connection and the startup of the client, and the 63 following requests share the connection that it opened.</p>
<h3>Running the map and the comparison lab</h3>
<p>The Compose profile <code>lab</code> starts <code>tile-map</code> on the port 8090, <code>tile-service</code> on the port 8443, the HTTP/2 only instance <code>tile-service-h2</code> on the port 9443 and the netem sidecar. Two variables adapt <code>tile-service</code> and the sidecar to a browser running on the host: <code>TIMING_ALLOW_ORIGIN</code> names the origin of <code>tile-map</code>, so that its page may read the protocol of each tile, and <code>NETEM_SIDES=1</code> applies the whole delay of a network profile to the packets that the servers send.</p>
<pre><code class="language-bash">TIMING_ALLOW_ORIGIN=https://localhost:8090 NETEM_SIDES=1 \
  docker compose --profile lab up -d --wait
</code></pre>
<p>The browser then requires three steps, because the certificate of the project is self-signed:</p>
<ol>
<li>Open <code>https://localhost:8443/tiles/0/0/0.png</code>, then <code>https://localhost:9443/tiles/0/0/0.png</code>, then <code>https://localhost:8090</code>, and accept the certificate on each origin. A browser presents no certificate prompt for an image of another origin, so each origin needs a visit of its own.</li>
<li>In Firefox, open <code>about:config</code> and set <code>network.http.http3.disable_when_third_party_roots_found</code> to <code>false</code>. Chromium instead needs the flags <code>--origin-to-force-quic-on=localhost:8090,localhost:8443</code> and <code>--ignore-certificate-errors-spki-list</code>, whose value the <code>README.md</code> file of the project explains how to compute.</li>
<li>Reload the map. The first load travels over HTTP/2 and delivers the <code>Alt-Svc</code> advertisements, and the second load travels over HTTP/3, which the green outline of each tile confirms.</li>
</ol>
<p>A click on a tile shows its metadata, fetched by <code>tile-map</code> from <code>tile-service</code> over HTTP/3. The link at the top of the map opens the lab at <code>https://localhost:8090/lab</code>, where the button <code>Run again</code> fetches both panels and the buttons <code>lan</code>, <code>wan</code>, <code>lossy</code> and <code>degraded</code> change the emulated network. The following command stops every container of the lab:</p>
<pre><code class="language-bash">docker compose --profile lab down
</code></pre>
<p>On Minikube, the Secret and the build of <code>tile-service</code> presented in the section "Deployment" come first. Each application then receives the address of the node, because each one refers to the other through it:</p>
<pre><code class="language-bash">eval $(minikube docker-env)
node=$(minikube ip)
env=quarkus.kubernetes.env.vars
mvn install -DskipTests -pl tile-service -am \
  -Dquarkus.container-image.build=true \
  -Dquarkus.kubernetes.deploy=true \
  -D$env.tiles-timing-allow-origin=https://$node:30090
mvn install -DskipTests -pl tile-map \
  -Dquarkus.container-image.build=true \
  -Dquarkus.kubernetes.deploy=true \
  -D$env.tiles-map-service-url=https://$node:30443
</code></pre>
<p>The map is then available at <code>https://&lt;node address&gt;:30090</code>, over TCP and UDP on the same port. The lab page explains on Minikube that its comparison requires the Compose profile, which provides the second origin and the sidecar.</p>
<h3>Running the benchmark</h3>
<p>The benchmark consists of two measurement scripts and one report program. The script <code>run.sh</code> runs the <code>h2load</code> scenarios and <code>rtt.sh</code> measures the round trips of individual requests with <code>curl</code>. Both run inside the benchmark image and append one CSV row per measurement to a file, without displaying any result. The program <code>Report.java</code> then reads these CSV files and writes the readable summary beside them, and the script <code>charts.sh</code> converts the charts of the summary into PNG images. The script <code>all.sh</code> chains the two measurement scripts, the report program and the conversion.</p>
<h4>Running the complete benchmark</h4>
<p>The script <code>benchmark/all.sh</code> generates the certificate when it is missing, starts the service and the sidecar with the address validation mode <code>BASIC</code>, runs <code>run.sh</code> and <code>rtt.sh</code>, repeats the HTTP/3 measurements with the mode <code>NONE</code>, stops the containers, and runs the report. A complete run takes about two hours:</p>
<pre><code class="language-bash">./benchmark/all.sh
</code></pre>
<h4>Where the results are written</h4>
<p>Without further setting, every output lands in the directory <code>benchmark/results</code>, the directory whose files this article presents:</p>
<table>
<thead>
<tr>
<th>File</th>
<th>Written by</th>
<th>Content</th>
</tr>
</thead>
<tbody><tr>
<td><code>results.csv</code></td>
<td><code>run.sh</code></td>
<td>One row per h2load run: duration, request rate, latencies, header bytes, losses</td>
</tr>
<tr>
<td><code>raw/</code></td>
<td><code>run.sh</code></td>
<td>The JSON output and the log of every h2load run</td>
</tr>
<tr>
<td><code>rtt-raw.csv</code></td>
<td><code>rtt.sh</code></td>
<td>One row per curl request: the timings of the connection, of TLS and of the first byte</td>
</tr>
<tr>
<td><code>summary.md</code></td>
<td><code>Report.java</code></td>
<td>The tables of this article, computed from both CSV files</td>
</tr>
<tr>
<td><code>rtt.csv</code></td>
<td><code>Report.java</code></td>
<td>The medians of <code>rtt-raw.csv</code> per group</td>
</tr>
<tr>
<td><code>rtt.svg</code>, <code>rtt-resumed.svg</code>, <code>rtt-earlydata.svg</code></td>
<td><code>Report.java</code></td>
<td>The charts of the round trips</td>
</tr>
<tr>
<td><code>rtt.png</code>, <code>rtt-resumed.png</code>, <code>rtt-earlydata.png</code></td>
<td><code>charts.sh</code></td>
<td>The same charts as images, for publishing platforms that accept no SVG</td>
</tr>
</tbody></table>
<p>The file to open after a run is therefore <code>summary.md</code>. It is a Markdown file, and pandoc displays its tables as aligned columns in the terminal, as the commands of the sections on short runs and on single scripts show, where <code>--columns=200</code> keeps the widest table on one line. The report runs again on existing measurements without repeating them:</p>
<pre><code class="language-bash">java benchmark/Report.java benchmark/results
</code></pre>
<p>The script <code>charts.sh</code> converts the SVG charts into PNG images through <code>rsvg-convert</code>, run in a temporary Alpine container, so that no local installation is required. It runs again after each report, on the directory that the report has written:</p>
<pre><code class="language-bash">benchmark/charts.sh benchmark/results
</code></pre>
<h4>The measurement files</h4>
<p>The two CSV files are the only source of the published figures. The scripts append to them and never rewrite them, and every other file of the directory derives from them, so that deleting <code>summary.md</code>, <code>rtt.csv</code> or the charts loses nothing that the report cannot recompute. Both files carry a header line, and a new file receives one before its first row.</p>
<p>The file <code>results.csv</code> contains one row per h2load run. Its times are in milliseconds:</p>
<table>
<thead>
<tr>
<th>Column</th>
<th>Meaning</th>
</tr>
</thead>
<tbody><tr>
<td><code>scenario</code></td>
<td><code>page-load</code>, <code>throughput</code>, <code>headers-sequential</code> or <code>headers-concurrent</code></td>
</tr>
<tr>
<td><code>profile</code></td>
<td>The network profile: <code>lan</code>, <code>wan</code>, <code>lossy</code> or <code>degraded</code></td>
</tr>
<tr>
<td><code>validation</code></td>
<td>The QUIC address validation mode of the service, <code>BASIC</code> or <code>NONE</code></td>
</tr>
<tr>
<td><code>protocol</code></td>
<td><code>h1</code>, <code>h2</code> or <code>h3</code></td>
</tr>
<tr>
<td><code>variant</code></td>
<td><code>default</code>, or <code>table0</code> for HTTP/2 with an HPACK dynamic table of size zero</td>
</tr>
<tr>
<td><code>iteration</code></td>
<td>The rank of the run within its group</td>
</tr>
<tr>
<td><code>duration_ms</code>, <code>req_s</code></td>
<td>The duration of the run and its request rate</td>
</tr>
<tr>
<td><code>request_median_ms</code>, <code>request_p95_ms</code></td>
<td>The median and the 95th percentile of the request times</td>
</tr>
<tr>
<td><code>connect_median_ms</code>, <code>connect_p95_ms</code></td>
<td>The same statistics for the connection establishment</td>
</tr>
<tr>
<td><code>ttfb_median_ms</code>, <code>ttfb_p95_ms</code></td>
<td>The same statistics for the first response byte</td>
</tr>
<tr>
<td><code>header_bytes</code>, <code>header_savings_pct</code></td>
<td>The header bytes on the wire and the savings relative to their decompressed size</td>
</tr>
<tr>
<td><code>packets_lost</code>, <code>smoothed_rtt_ms</code></td>
<td>The QUIC statistics of h2load, present for HTTP/3 only</td>
</tr>
<tr>
<td><code>failed</code></td>
<td>The number of requests that failed, raised an error or exceeded the h2load time limit</td>
</tr>
</tbody></table>
<p>The file <code>rtt-raw.csv</code> contains one row per curl request for the tile <code>/tiles/3/2/1.png</code>. Its times are in seconds, measured by curl from the start of the request:</p>
<table>
<thead>
<tr>
<th>Column</th>
<th>Meaning</th>
</tr>
</thead>
<tbody><tr>
<td><code>profile</code>, <code>validation</code>, <code>protocol</code></td>
<td>As in <code>results.csv</code></td>
</tr>
<tr>
<td><code>mode</code></td>
<td><code>cold</code> for a new TLS session, <code>resumed</code> for a session resumed from a saved ticket, <code>earlydata</code> for a resumed session that also requests 0-RTT</td>
</tr>
<tr>
<td><code>sample</code></td>
<td>The rank of the request within its group</td>
</tr>
<tr>
<td><code>time_connect</code></td>
<td>The end of the transport connection</td>
</tr>
<tr>
<td><code>time_appconnect</code></td>
<td>The end of the TLS handshake, which QUIC performs together with its own handshake</td>
</tr>
<tr>
<td><code>time_pretransfer</code>, <code>time_starttransfer</code>, <code>time_total</code></td>
<td>The sending of the request, the first response byte and the last response byte</td>
</tr>
<tr>
<td><code>http_version</code></td>
<td>The protocol that curl actually used</td>
</tr>
<tr>
<td><code>tls_earlydata</code></td>
<td>The number of bytes that curl sent as early data</td>
</tr>
<tr>
<td><code>exit_code</code></td>
<td>The exit code of curl, where any value other than zero marks a failed request, mostly the expiry of its time limit</td>
</tr>
</tbody></table>
<h4>How the report computes the summary</h4>
<p><code>Report.java</code> is a single file Java program, which the Java launcher compiles and runs in one step, without Maven. It takes the directory that holds the two CSV files as its only argument, <code>benchmark/results</code> by default, reads both files, and writes <code>summary.md</code>, <code>rtt.csv</code> and the charts into that same directory, replacing the previous versions. A missing CSV file produces empty tables.</p>
<p>The report forms groups and reduces each group to a few statistics:</p>
<ol>
<li>A row of HTTP/3 becomes <code>h3-basic</code> or <code>h3-none</code> according to its validation mode, which separates the two configurations of QUIC in every table. The report ignores the rows of HTTP/1.1 and HTTP/2 measured with the mode <code>NONE</code>, since this mode concerns QUIC only.</li>
<li>The round trip table groups the rows of <code>rtt-raw.csv</code> by profile, protocol and mode. It counts the requests whose exit code differs from zero as failed and excludes them, then computes the median and the 95th percentile of each curl time. It also divides each time by the round trip time of the profile, 50 milliseconds for <code>wan</code>, <code>lossy</code> and <code>degraded</code>, which expresses it as a number of round trips. The file <code>rtt.csv</code> contains these statistics, and the charts show the medians of the connection, of the handshake and of the first byte as stacked bars, one chart for each mode.</li>
<li>The page load and throughput tables group the rows of <code>results.csv</code> by scenario, profile, protocol and variant. They count the runs that contain at least one failed request, and they compute the median and the 95th percentile over the other runs only, because a single request that waits until the h2load time limit would otherwise dominate the result.</li>
<li>The header compression table keeps every run, since its byte counts are meaningful even when a request fails, and reports the median of the header bytes and of the savings.</li>
</ol>
<p>Two consequences follow for the use of the report. Every row present in a CSV file enters its group, so that a second run with the same settings adds iterations to the first one instead of replacing it. Moreover, the round trip times of the profiles are written in the program itself, in the constant <code>PROFILE_RTT_MS</code>, which must follow any change of the delays in <code>netem.sh</code>.</p>
<h4>Short runs that keep the published results intact</h4>
<p>Because both scripts append to their CSV files, a short run made in <code>benchmark/results</code> mixes its rows with the published measurements. The variable <code>RESULTS_DIR</code> of <code>all.sh</code> names a subdirectory of <code>benchmark/results</code> that receives both CSV files and the report instead. The subdirectory <code>debug</code> stays outside version control. Environment variables also reduce the scope of a run:</p>
<ul>
<li><code>PROFILES</code> selects the network profiles;</li>
<li><code>PROTOCOLS</code> the protocols among <code>h1</code>, <code>h2</code> and <code>h3</code>;</li>
<li><code>SCENARIOS</code> the <code>h2load</code> scenarios among <code>page-load</code>, <code>throughput</code> and <code>headers</code>;</li>
<li><code>ITERATIONS</code> and <code>REPEATS</code> the number of runs of the page load scenario and of the other scenarios;</li>
<li><code>SAMPLES</code> the number of <code>curl</code> requests per group.</li>
</ul>
<p>The following command measures the page load and the round trips over HTTP/2 and HTTP/3 on the wide area network in less than two minutes, then displays the summary:</p>
<pre><code class="language-bash">RESULTS_DIR=debug PROFILES=wan PROTOCOLS="h2 h3" SCENARIOS=page-load \
  ITERATIONS=2 REPEATS=1 SAMPLES=5 ./benchmark/all.sh
pandoc -f gfm -t plain --columns=200 benchmark/results/debug/summary.md
</code></pre>
<p>The JSON files of <code>h2load</code> always go to <code>benchmark/results/raw</code>, which version control ignores, and a later run with the same scenario, profile, protocol and iteration replaces them.</p>
<h4>Running a single script</h4>
<p>The scripts <code>run.sh</code> and <code>rtt.sh</code> also run on their own, against a service started as shown earlier. The variable <code>RESULTS_CSV</code> designates the output file of <code>run.sh</code> and <code>RTT_OUT</code> that of <code>rtt.sh</code>, both as paths inside the container, where <code>benchmark</code> is mounted at <code>/benchmark</code>. Without them, the scripts append to the published files. The directory must exist before the run, because a directory that the container creates belongs to the user <code>root</code>, and the report then cannot write into it. The report runs on the directory that holds the two files:</p>
<pre><code class="language-bash">mkdir -p benchmark/results/debug
docker compose up -d --wait tile-service netem
docker compose run --rm -e PROFILES=wan -e PROTOCOLS="h2 h3" \
  -e SCENARIOS=page-load -e ITERATIONS=2 \
  -e RESULTS_CSV=/benchmark/results/debug/results.csv bench ./run.sh
docker compose run --rm -e PROFILES=wan -e PROTOCOLS="h2 h3" \
  -e SAMPLES=5 -e RTT_OUT=/benchmark/results/debug/rtt-raw.csv \
  bench ./rtt.sh
docker compose --profile bench down
java benchmark/Report.java benchmark/results/debug
benchmark/charts.sh benchmark/results/debug
pandoc -f gfm -t plain --columns=200 benchmark/results/debug/summary.md
</code></pre>
<p>Rows accumulate across runs in the same files, with <code>all.sh</code> as with the scripts alone, so removing <code>results.csv</code> and <code>rtt-raw.csv</code> from <code>benchmark/results/debug</code> before a new exploration keeps its summary limited to that exploration.</p>
<h2>Limitations</h2>
<p>The extension is experimental, and its configuration and behavior may change. WebSocket connections use HTTP/1.1 or HTTP/2, because Vert.x supports no WebSocket over HTTP/3. Many corporate networks filter UDP, in which case browsers keep using HTTP/2 after a failed attempt, whereas the REST client configured for HTTP/3 fails. Native compilation requires the QUIC native library of the target platform. On networks that lose packets, some HTTP/3 requests never complete, because of the quiche defect that Netty 4.2.20 bundles. The read timeout of the REST client never ends an HTTP/3 request, so every HTTP/3 call needs a time limit of its own. The receive buffer of the QUIC sockets keeps the system default, which a burst of responses can exceed even on the loopback interface.</p>
<h2>Conclusion</h2>
<p>The <code>quarkus-http3</code> extension fulfils its essential promise. With a dependency and a few properties, a Quarkus 4.0.1 application serves HTTP/1.1, HTTP/2 and HTTP/3 on one HTTPS port, advertises HTTP/3 to its clients, and calls other services over HTTP/3 with the REST client. Three defects of the extension required workarounds in this project: </p>
<ul>
<li>the loss of the HTTP/2 response header fields caused by the <code>ALTSVC</code> frame;</li>
<li>the startup failure when HTTP/3 is disabled;</li>
<li>the request header limit that applies to TCP only.</li>
</ul>
<p>Each workaround remains small and is covered by a test that detects when it becomes unnecessary.</p>
<p>The measurements show that the advantage of HTTP/3 depends on its configuration. With the default address validation mode <code>BASIC</code>, the Retry packet consumes the round trip that QUIC saves, and a new HTTP/3 connection delivers its first response byte after three round trips, exactly as HTTP/2 over TCP and TLS 1.3 does. With the mode <code>NONE</code>, the first response byte arrives after two round trips, 50 milliseconds earlier on the emulated wide area network, and a page of 64 tiles loads 46 milliseconds faster. This mode removes the verification of the client address. The choice between the two modes therefore weighs one round trip per new connection against the protection of the server from connection attempts with forged addresses, and it belongs to the operators of each deployment. Session resumption and 0-RTT, the third mechanism that QUIC offers to save round trips, remain unused, since Vert.x never enables early data, whatever the configuration.</p>
<p>Header compression shows the same distance between the protocol and its implementation. QPACK provides a dynamic table equivalent to that of HPACK, but Vert.x disables it, and HTTP/3 saves 39 percent of the header bytes of the repetitive <code>meta</code> operation, where HTTP/2 saves 98 percent. Applications that send large and repetitive header fields, such as cookies or authorization tokens, therefore transmit more header bytes over HTTP/3 than over HTTP/2 with Quarkus 4.0.1.</p>
<p>On networks that lose packets, the current stack reverses the expected result. HTTP/3 loads a page more slowly than HTTP/2 with 1 and 5 percent loss, and some requests never complete, because the <code>quiche</code> revision that Netty bundles discards a lost end of stream instead of retransmitting it. Since the HTTP client of Vert.x never ends an HTTP/3 request through its timeout, such a request blocks its caller until a time limit set by the application ends it. The <code>quiche</code> project has corrected this defect, and its correction reaches Quarkus applications once Netty, then Vert.x and Quarkus, adopt it. Until then, an application that targets wireless or mobile users benefits from keeping HTTP/2 available alongside HTTP/3, and a service that calls other services across networks with loss benefits from configuring its REST client for HTTP/2.</p>
<p>HTTP/3 in Quarkus 4.0.1 is therefore an experimental capability that already demonstrates the mechanisms of QUIC and the integration of a modern protocol into a Java framework, and whose performance advantages depend on choices made in Vert.x, Netty and <code>quiche</code>. This support is conformant, but it has not yet reached the maturity that production use requires, for four reasons established in this article: </p>
<ul>
<li>requests that never complete on networks that lose packets;</li>
<li>the three defects of the extension;</li>
<li>the optimizations of the protocol that remain disabled, namely the QPACK dynamic table, 0-RTT and the configuration of address validation;</li>
<li>the experimental status that Quarkus itself assigns to the extension.</li>
</ul>
<p>The benchmark of this project can be run again with each new release of these components. By gathering the following:</p>
<ul>
<li>the round trip saved by the removal of the Retry packet;</li>
<li>the round trip that 0-RTT would save;</li>
<li>the compression ratio that the QPACK dynamic table would provide;</li>
<li>the behavior of HTTP/3 on networks that lose packets;</li>
</ul>
<p>running repeatedly the benchmark makes the progression of these advantages directly measurable.</p>
]]></content:encoded></item><item><title><![CDATA[Distributed Transactions in Enterprise Applications: From X/Open to MicroProfile LRA with Quarkus]]></title><description><![CDATA[The problem of making several independent systems agree on a single outcome is older than most of the technology used to solve it. Historically, one of the…]]></description><link>https://nicolasduminil.hashnode.dev/distributed-transactions-in-enterprise-applications-from-x-open-to-microprofile-lra-with-quarkus</link><guid isPermaLink="true">https://nicolasduminil.hashnode.dev/distributed-transactions-in-enterprise-applications-from-x-open-to-microprofile-lra-with-quarkus</guid><category><![CDATA[quarkus]]></category><category><![CDATA[Java]]></category><category><![CDATA[lra]]></category><dc:creator><![CDATA[nicolasduminil]]></dc:creator><pubDate>Wed, 25 Nov 2026 15:26:45 GMT</pubDate><content:encoded><![CDATA[<h2>Abstract</h2>
<p>The problem of making several independent systems agree on a single outcome is older than most of the technology used to solve it. Historically, one of the first protocols able to provide this synchronization was 2PC (<em>two-phase commit</em>) that the application servers era made an ordinary feature of enterprise development. Later lightweight frameworks, service-oriented and microservices architectures have made the same guarantee considerably harder to obtain.<br />This article follows that problem from its formalization in the X/Open Distributed Transaction Processing to the present situation. It then examines two working implementations of an identical use case, one using XA and two-phase commit, the other using the saga pattern, as specified by MicroProfile LRA, and compares them on evidence rather than on preference. The accompanying source code is available in the <a href="https://github.com/nicolasduminil/quarkus-distributed-tx"><code>quarkus-distributed-tx</code></a> repository, where both implementations expose the same REST contract and are exercised by the same test suite.</p>
<hr />
<h2>1. Origins: X/Open, and the Formalization of 2PC</h2>
<p>The 2PC protocol is older than the standard that made it famous. Its essential shape appears in the database literature of the late 1970s, notably in the work of Jim Gray on the recovery and consistency properties of database operating systems. The problem it addresses is easy to state and difficult to solve: several parties must all either perform or decline an action. And they must do that despite the possibility that any of them, including the party conducting the negotiation, may fail at any moment.</p>
<p>As its name states, the protocol proceeds in two phases. In the first, the coordinator asks every participant whether it is able to commit. A participant that answers affirmatively cannot retract itself. It must have written enough durable state to guarantee that it can still commit even after a crash. In the second phase, the coordinator informs the participants of the collective decision, which is affirmative only if every vote was affirmative.</p>
<p>In early '90s, the X/Open consortium decided to contribute by formalizing a reference model named DTP (<em>Distributed Transaction Processing</em>). This model identified three roles namely the application program, the transaction manager and the resource manager. The following two interfaces have been defined:</p>
<ul>
<li>the TX (<em>Transaction Demarcation</em>) interface governs how an application demarcates a transaction;</li>
<li>the XA (<em>eXtended Architecture</em>) interface defines how the transaction manager drives the resource manager through the phases of the commit.</li>
</ul>
<p>Once the XA specifications existed, a transaction manager written by one vendor could coordinate a database written by another, and the industry acquired a genuinely portable mechanism for distributed atomicity.</p>
<p>Let's note a property of the XA specifications that will become important later. Between the moment a participant votes to commit and the moment it learns the collective decision, it is <em>blocked</em>. It holds its locks, it cannot proceed, and it cannot unilaterally decide. If the coordinator fails during this interval, the participant waits. Skeen and others demonstrated in the early '80s that this blocking behavior is not an artifact of a careless design but a logical consequence of the quorum-based model which tolerates partitions only by blocking whenever no quorum can be assembled. In 1985, Fischer, Lynch and Paterson published the article <em>Impossibility of Distributed Consensus with One Faulty Process</em> which establishes that deterministic consensus cannot be guaranteed in an asynchronous system in which even one process may fail.</p>
<p>Because of this vulnerability 2PC was considered in the beginning a flawed protocol that needed improvements. It took some time and experience to understand that, on the opposite, it's an exact trade-off between perfect atomicity and availability.</p>
<h2>2. Several Decades of Service</h2>
<p>It would be reasonable to expect that a protocol with a documented blocking failure mode and a known vulnerability would have been superseded. It has not been. 2PC remains the most widely deployed mechanism for distributed atomicity in enterprise systems, and it is likely to remain so for some time.</p>
<p>The explanation is that the failure mode is rare and the guarantee is absolute. Within a single data center, coordinating two databases and a message broker across a reliable local network, with a transaction manager whose recovery log is on durable storage, the vulnerable interval is measured in milliseconds and the recovery procedure is automatic. Financial institutions, telecommunications operators and government systems adopted the protocol because the alternative was to write compensation logic by hand for every business operation. Additionally, software architects and developers are more confident in a protocol than in a promise that reconciliation will probably catch any discrepancies.</p>
<p>Another important point to notice is that 2PC places complexity in the infrastructure field, written once, by specialists, and consumed through a single annotation. Every other alternative examined in this article moves that work into application code, where it must be written again for each operation, by developers whose principal expertise is the business domain rather than distributed systems. This is a real cost and it is frequently underestimated.</p>
<h2>3. OTS, JTS and JTA</h2>
<p>The X/Open model assumed a particular shape: an application, a transaction manager and some resource managers, generally within reach of one another. What it did not address is the case that the OO (<em>object-oriented</em>) paradigm made central the concept of transactions spanning objects that reside in different processes, on different machines, supplied by different vendors, and invoked remotely as though they were local.</p>
<p>The OMG (<em>Object Management Group</em>), the consortium behind CORBA, answered this in the mid-1990s with the OTS (<em>Object Transaction Service</em>), adopted as one of the CORBAservices. OTS described the roles of a distributed transaction in CORBA's IDL (<em>Interface Definition Language</em>). The protocol underneath had not changed, the same resources, participants and quorum, in Gray's sense, were at work and no new algorithms have been proposed. OTS only specified how the 2PC participants might be distributed objects. And it settled the question that X/Open had left thin, namely how two transaction managers, from different vendors, should interoperate.</p>
<p>OTS didn't displace XA but complemented it. The boundary to the resources, like databases or message brokers, remained what it had been, OTS typically only fronted resource managers driven over XA. Anything that OTS added sat above that boundary, between the managers themselves.</p>
<p>The Jakarta EE platform, formerly Java EE and even formerly J2EE, absorbed this model with considerable thoroughness. The JTA (<em>Java Transaction API</em>) specifications defined the interface through which applications and application servers demarcate transactions. JTS (<em>Java Transaction Service</em>) brought OTS into Java. It required a transaction manager to implement that specification in its Java-mapped form, to propagate transaction context between managers as OTS prescribed, and to present JTA to the layer above. JTS was therefore not an alternative design but OTS in Java, with a JTA façade.</p>
<p>The distinction between JTA and JTS is worth mentioning as the two are habitually confused, usually as "JTA is the interface and JTS the implementation". That is not quite it, since both are specifications. JTA is what an application programmer sees: <code>UserTransaction</code>, <code>TransactionManager</code>, and the interfaces by which resources are enlisted. JTS specifies what provides the guarantee underneath, including the propagation of transaction context between processes and the interoperability of transaction managers from different vendors.</p>
<p>For the application developer, the effect was remarkable and is easily forgotten now. A method annotated for container-managed transactions would, upon invoking a remote component, carry its transaction context to that component, enlist the remote resources, and commit or roll back the entire assembly atomically. The programmer wrote business logic. The container arranged consensus. This was one of the genuinely impressive achievements of the enterprise Java period which worked reliably across products from competing vendors and it is somewhat unfair that it is now remembered as an old labyrinthine system.</p>
<h2>4. CORBA and IIOP as the Transport of Context</h2>
<p>The transaction context propagation just described required a mechanism, and the mechanism was CORBA. Transaction context traveled between application servers as part of the IIOP (<em>Internet Inter-ORB Protocol</em>), in the form of a service context attached to the remote invocation. OTS defined how that context was represented and how transaction managers should interoperate. IIOP carried it.</p>
<p>This arrangement was possible because <strong>the transport understood transactions</strong>. A remote call was not merely a message but an invocation within a transactional context, and the infrastructure at both ends recognized it as such. Enlistment of the remote resource was automatic because the protocol carried the information required to perform it.</p>
<p>The costs were substantial. CORBA was complex, its interoperability was achieved by considerable effort and its programming model demanded interface definitions and generated stubs. As the industry moved towards HTTP and simpler representations, these costs became decisive. But it is important to record that the price of the simplicity was HTTP lack of capacity to carry transactional semantics.</p>
<h2>5. The Decline of Heavyweight Servers and the Rise of Lighter Frameworks</h2>
<p>The reasons for the decline of the traditional application server are well documented and only tangentially concerned with transactions. Deployment units grew large and start-up times grew long at exactly the moment when elastic infrastructure began to reward the opposite. Container images preferred a single process to a shared runtime hosting many applications. The operational model of the application server, in which several applications share a managed container administered by a specialist team, was displaced by one in which each service carries its own runtime and is administered by the team that wrote it.</p>
<p>Spring Boot, released in 2014, demonstrated that an embedded server and convention-based configuration could deliver most of the productivity of the enterprise stack with a fraction of its ceremony. Quarkus, which followed in 2019, went further by moving substantial work from run time to build time, producing start-up characteristics that make Java a plausible choice for serverless and elastically scaled deployments.</p>
<p>Jakarta EE itself, transferred to the Eclipse Foundation in 2017 and subsequently renamed, continues to evolve, and both Spring Boot and Quarkus rely on substantial parts of its specifications. The change is therefore less a repudiation of the enterprise Java model than a redistribution of it. The specifications survived, the monolithic container that implemented them did not.</p>
<h2>6. What the Lighter Frameworks Lost</h2>
<p>Two changes occurred simultaneously. The first is architectural. The microservice architecture style holds that each service should own its data, and that no other service should reach into that data directly. This principle is incompatible with 2PC across services which requires the coordinator to be connected to the resource managers. A coordinator that must not touch another service's resources cannot enlist them.</p>
<p>The second is a matter of transport. HTTP does not propagate transaction context. It doesn't provide an equivalent of the IIOP service context. A REST call is an independent interaction whose relationship to the caller's transaction is not represented anywhere, unless the application arranges to represent it.</p>
<p>The consequence, which is regularly misunderstood in practice, is that annotating a method as transactional and then invoking a remote service from within it produces no distributed transaction of any kind. If the local transaction rolls back, the remote effect stands. If the local transaction commits, nothing establishes that the remote one did, and a remote call that returned no answer may have applied its change or may not, leaving the caller no basis on which to decide. The divergence does not even require the remote service to fail. The arrangement has the appearance of a distributed transaction and none of the substance, which is the least desirable of the available outcomes, since it fails while presenting the appearance of success.</p>
<h2>7. The Saga Pattern, and the Ease of Implementing It Incorrectly</h2>
<p>The saga was described by Garcia-Molina and Salem in 1987, in a paper concerned with long-lived transactions within a single database. Their observation was that a transaction holding locks for a long period is destructive to concurrency, and that certain long transactions may be decomposed into a sequence of shorter ones, each of which commits independently, with a compensating transaction defined for each step. If the sequence cannot be completed, the compensations for the completed steps are executed in reverse order.</p>
<p>The saga doesn't provide isolation. This is not a defect of a particular implementation but by definition. Intermediate states are visible to other observers, because each step has genuinely committed. In exchange, no participant holds a lock while waiting for a distant coordinator, and each service retains authority over its own data.</p>
<p>The naive implementation, which is very common, executes each step and defines its compensation as the arithmetic inverse. Let's consider the example of a money transfer service, like the one presented in the associated project. A debit is compensated by a credit of the same amount. This is wrong in two distinct ways.</p>
<p>The first defect is the visible intermediate state. Between the debit and its compensation, the balance is genuinely reduced. Any concurrent observer, including another saga evaluating whether sufficient funds exist, will read that reduced value and may act upon information that is about to be invalidated.</p>
<p>The second defect is that <strong>the compensating action can itself fail</strong>. A credit is an operation like any other, subject to validation, to constraints, and to the account having been closed in the interval. A saga whose compensation fails is in a worse condition than one that never began, since it has performed part of an operation and it cannot undo it. The system requires human intervention, and the humans require an explanation.</p>
<p>The remedy, illustrated in Section 10, is to arrange matters so that no compensating write is required. If the first step reserves rather than acts, then compensation releases the reservation, and a release cannot fail for business reasons because it removes an obligation rather than creating one.</p>
<h2>8. MicroProfile LRA</h2>
<p>MicroProfile LRA, where LRA denotes <em>Long Running Action</em>, specifies a saga coordination protocol for services communicating over HTTP. It is best understood as an answer to the two negative effects identified in Section 6: it reintroduces a context that travels with the call, and it reintroduces a coordinator that drives participants to a common outcome. It does not, and cannot, reintroduce atomicity.</p>
<p>The programming model is declarative. A method annotated <code>@LRA</code> participates in a long-running action, beginning one if required. Context propagates in the <code>Long-Running-Action</code> HTTP header, which the implementation attaches to outgoing calls and interprets on incoming ones. A participant declares its obligations through further annotations:</p>
<ul>
<li><code>@Compensate</code>, which is invoked if the action is cancelled;</li>
<li><code>@Complete</code>, invoked if it is closed successfully;</li>
<li><code>@Status</code>, by which the coordinator may enquire what a participant did;</li>
<li><code>@Forget</code>, by which a participant may discard state it no longer needs to retain.</li>
</ul>
<p>Two properties of this protocol are commonly overlooked. The first is that participants must be <strong>idempotent</strong>. The coordinator retries. A participant that applies its effect a second time corrupts its own data. This is the requirement that appears in every specification document and is absent from a remarkable proportion of first implementations.</p>
<p>The second is that the coordinator is a <strong>separate process that calls the participants back</strong>. As opposed to JTA where the transaction manager is embedded in the application, under LRA it is not and the participant must reach the coordinator to begin, join and end an action. The coordinator must reach every participant to invoke its callbacks. It is entirely possible to construct a deployment in which the first direction works as expected while the second does not, and the resulting behavior is discussed in Section 10.</p>
<hr />
<h2>9. The XA Implementation in Detail</h2>
<p>The use case is deliberately modest: transfer an amount from one account to another and record the transfer. Two databases are involved, one holding accounts and one holding the transfer log, because a single database would reduce the problem to a local transaction and demonstrate nothing.</p>
<p>One component in this arrangement is essential: the Narayana transaction manager. Its lineage is running back to the Arjuna research at the University of Newcastle and provided two decades of good service as the transaction manager of JBoss and WildFly. Its Quarkus extension, used here, brings a JTA implementation embedded in the application's own process. It owns the object store, decides the outcome and executes the 2PC protocol on the application's behalf. The same project supplies the LRA coordinator that section 10 relies upon, so both implementations in this article rely on the same body of code.</p>
<h3>Configuration</h3>
<p>Each datasource is declared as an XA one:</p>
<pre><code class="language-properties">quarkus.datasource.accounts.jdbc.transactions=xa
quarkus.datasource.xfers.jdbc.transactions=xa
</code></pre>
<p>That flag is the entire mechanism. The connection pool supplies <code>XAConnection</code> instances rather than ordinary ones, and each pool enlists an <code>XAResource</code> in the active transaction upon first use.</p>
<h3>The transactional method</h3>
<pre><code class="language-java">@Transactional
public TransferDto processTransfer(TransferRequest request)
{
  Account source = accountRepository.getAccount(request.getSourceAccountId())
    .orElseThrow(() -&gt; new AccountNotFoundException(request.getSourceAccountId()));
  Account destination = accountRepository.getAccount(request.getDestinationAccountId())
    .orElseThrow(() -&gt; new AccountNotFoundException(request.getDestinationAccountId()));
  if (source.getBalance().compareTo(request.getAmount()) &lt; 0)
    throw new InsufficientFundsException(source.getId());
  source.debit(request.getAmount());
  destination.credit(request.getAmount());
  Transfer transfer = new Transfer(Common.getRandomId(), source.getId(), destination.getId(),
        request.getAmount(), request.getCurrency(), TransferStatus.COMPLETED, LocalDateTime.now());
  transferRepository.createTransfer(transfer);
  return transfer.toDto();
}
</code></pre>
<p>There is no reference to two-phase commit in this code, and that is the observation worth recording. The annotation causes a JTA transaction to begin. The two repositories address two different datasources. Each datasource enlists itself. When the method returns, Narayana performs the protocol.</p>
<h3>The protocol as executed</h3>
<p>Upon commit the transaction manager calls <code>prepare</code> on both branches. Each PostgreSQL instance executes <code>PREPARE TRANSACTION</code>, writing the changes durably in a state from which they can still either be committed or rolled back. If both branches vote affirmatively, the transaction manager writes its decision to its object store. This is the point at which the outcome becomes irrevocable and then the transaction manager calls <code>commit</code> on both branches, each of which executes <code>COMMIT PREPARED</code>.</p>
<p>Two consequences of operational importance follow. PostgreSQL refuses prepared transactions unless <code>max_prepared_transactions</code> is configured with a positive value, its default being zero, so an otherwise correct application fails at the first commit. And the transaction manager's object store must be durable, since it holds the only record of a decision made but not yet applied. Recovery must be enabled so that transactions left in doubt by a failure are resolved when the process returns.</p>
<h3>The architectural cost</h3>
<p>The transfer service interacts directly with the <code>accounts</code> database. It does not ask anything of the account service, it holds the resource manager instead. This means that it owns a connection to the <code>accounts</code> database and enlists it in its own transaction. The transfer service opens that connection, modifies the account rows itself through its own persistence layer, and the <code>XAResource</code> behind that connection becomes a branch of the transaction that the transfer service began. The account service plays no part. Its code does not run and it is not informed. The commit decision belongs to the transfer service's transaction manager.</p>
<p>This is not an oversight but a requirement. <code>prepare</code> and <code>commit</code> are operations on an <code>XAResource</code>, and a service boundary exposes no equivalent of them. HTTP offers no way to ask a remote service to make a change durable while leaving its outcome open. A coordinator that cannot reach the resource manager cannot enlist it. The consequence is that the two services need to share a database, and the independence that the service boundary was intended to establish is not present. The repository's <code>docker-compose.yaml</code> states this fact in one line: <code>transfer</code> is given its own database, as well as the accounts datasource URL, whereas <code>transfer-lra</code> is given, in addition to its own database URL, the one of the account service.</p>
<h2>10. The LRA Implementation in Detail</h2>
<p>The saga implementation exposes an identical REST contract and reaches balances only through the account service's HTTP interface. It has no dependency on the accounts persistence layer, and that absence is the entire architectural point.</p>
<h3>Reserve, then confirm</h3>
<p>In the LRA implementation and as opposed to the 2PC one, the account service does not move money when asked to reserve a debit. It records a <code>Reservation</code> in state <code>PENDING</code> and leaves the balance unchanged. Available funds are computed as the balance minus the sum of pending debits, so another possible concurrent saga cannot reserve the same money. Upon <code>@Complete</code> the reservations are applied; upon <code>@Compensate</code> they are released.</p>
<p>Accordingly, <strong>because the balance never moved, compensation performs no update and, therefore, no persistence operation can fail during compensation.</strong> Hence, the second issue identified in Section 7 is eliminated by construction rather than by coding.</p>
<h3>Idempotency, enforced twice</h3>
<p>Reservations are identified, in business terms, by a triple consisting in the action identifier, the account and the reservation type. Notice that the triple is not the entity's primary key, which is a generated value, so nothing in the object model prevents a second row carrying the same triple. And in order to avoid that, it is declared as a unique constraint in the database:</p>
<pre><code class="language-java">@Table(name = "RESERVATIONS",
  uniqueConstraints = @UniqueConstraint(name = "UK_RESERVATION_LRA",
    columnNames = {"LRA_ID", "ACCOUNT_ID", "RESERVATION_TYPE"}))
</code></pre>
<p>The constraint is needed because the account service, when asked to reserve a debit, looks for an existing reservation before writing one, which is a check-then-act sequence and, therefore, not atomic. Two deliveries of the same reserve request can both find nothing and both insert. The constraint avoids that and guarantees that the database refuses the 2nd reserve.</p>
<p>Retries could also cause the effect described above. The coordinator waits for each callback, but a call that times out or whose reply is lost leaves the action unresolved, so it keeps calling again and again. A settlement instruction therefore might arrive more than once for a reservation that is already recorded. The database constraint cannot help here, since no row is being inserted. Then the guard sits one level down, in the service class shown below. As you can see, the two callbacks annotated with <code>@Compensate</code> and <code>@Complete</code> annotations obtain their reservations from a single helper, the <code>pendingFor(...)</code> method, that selects only the <code>PENDING</code> reservations, so that the ones already confirmed or already released are passed over rather than settled again.</p>
<pre><code class="language-plaintext">@ApplicationScoped
public class AccountLraService
{
  ...
  @Transactional
  public ParticipantStatus complete(String lraId)
  {
    pendingFor(lraId).forEach(this::confirm);
    return ParticipantStatus.Completed;
  }
  ...
  @Transactional
  public ParticipantStatus compensate(String lraId)
  {
    pendingFor(lraId).forEach(reservation -&gt; reservation.setState(ReservationState.RELEASED));
    return ParticipantStatus.Compensated;
  }
  ...
  private Stream&lt;Reservation&gt; pendingFor(String lraId)
  {
    return reservations.findByLra(lraId).stream()
     .filter(reservation -&gt; reservation.getState() == ReservationState.PENDING);
  }
  ...
}  
</code></pre>
<h2>11. The Project</h2>
<p>The project that illustrates this article is a Quarkus workshop, available at <a href="https://github.com/nicolasduminil/quarkus-distributed-tx"><code>quarkus-distributed-tx</code></a>, showing a simple money transfer use case in the two ways that we discussed along the article:</p>
<ul>
<li><strong>XA / 2PC</strong> (<code>transfer</code>, port 8080): a genuine 2PC across two XA datasources, coordinated by Narayana.</li>
<li><strong>Saga / MicroProfile LRA</strong> (<code>transfer-lra</code>, port 8090 and <code>account</code>, port 8081): a compensation-based consistency example across autonomous services, coordinated by a Narayana LRA coordinator.</li>
</ul>
<p>Both expose the same <code>/xfers</code> REST contract and are driven by the same shared test suite (<code>transfer-tck</code>), so any difference you observe is a difference in transaction strategy and nothing else.</p>
<h3>Modules</h3>
<p>The following modules are part of the workshop project.</p>
<table>
<thead>
<tr>
<th>Module</th>
<th>Role</th>
</tr>
</thead>
<tbody><tr>
<td><code>common</code></td>
<td>Shared library: <code>Common</code> utility, the transfer DTOs (<code>TransferDto</code>, <code>TransferRequest</code>, <code>TransferResponse</code>, <code>TransferStatus</code>), the application exception hierarchy and the single <code>ApplicationExceptionMapper</code> that maps them to HTTP status codes.</td>
</tr>
<tr>
<td><code>account-repository</code></td>
<td>Shared persistence layer for accounts: the <code>Account</code> entity, <code>AccountDto</code>, the <code>AccountRepository</code> interface and its two implementations. Depended on by <code>account</code> and by <code>transfer</code> — and pointedly <strong>not</strong> by <code>transfer-lra</code>.</td>
</tr>
<tr>
<td><code>transfer-tck</code></td>
<td>The REST contract both transfer implementations must satisfy, as an abstract test class. Test tooling is at compile scope so consumers depend on it with <code>&lt;scope&gt;test&lt;/scope&gt;</code>.</td>
</tr>
<tr>
<td><code>account</code></td>
<td>Account microservice (port 8081). Owns the <code>accounts</code> schema. CRUD + debit/credit, <strong>plus</strong> the LRA participant endpoints under <code>/lra/accounts</code>.</td>
</tr>
<tr>
<td><code>transfer</code></td>
<td>XA coordinator (port 8080). Two XA datasources (<code>accounts</code>, <code>xfers</code>). Transfer CRUD plus the 2PC transfer operation.</td>
</tr>
<tr>
<td><code>transfer-lra</code></td>
<td>Saga orchestrator (port 8090). One plain datasource for its own transfer log; reaches balances only through the account service's API.</td>
</tr>
</tbody></table>
<p>Each repository has two implementations: an in-memory one (<code>DefaultAccountRepository</code>, <code>DefaultTransferRepository</code>) and a JPA/Panache one (<code>AccountRepositoryXA</code>, <code>TransferRepositoryXA</code>). Both are <code>@Alternative</code>, so neither is enabled by default; each application picks the XA pair explicitly through <code>quarkus.arc.selected-alternatives</code>. Only the XA implementations participate in 2PC — the in-memory ones are there to run the services without a database.</p>
<p>All four modules carry the Jandex plugin so their <code>@Entity</code>, <code>@Provider</code> and CDI bean classes are indexed when consumed as external dependencies.</p>
<h3>Endpoints</h3>
<p>Three services expose an HTTP API, each with a Swagger UI at <code>/q/swagger-ui</code>. The rows marked as callbacks are invoked by the LRA coordinator, not by clients.</p>
<table>
<thead>
<tr>
<th>Service</th>
<th>Method</th>
<th>Path</th>
<th>Purpose</th>
</tr>
</thead>
<tbody><tr>
<td><code>account</code> (8081)</td>
<td><code>GET</code></td>
<td><code>/accounts</code></td>
<td>List the accounts</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>POST</code></td>
<td><code>/accounts</code></td>
<td>Create an account</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>GET</code></td>
<td><code>/accounts/{accountId}</code></td>
<td>Read one account</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>PUT</code></td>
<td><code>/accounts/{accountId}</code></td>
<td>Update one account</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>DELETE</code></td>
<td><code>/accounts/{accountId}</code></td>
<td>Delete one account</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>POST</code></td>
<td><code>/accounts/{accountId}/debit</code></td>
<td>Debit, amount in the body</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>POST</code></td>
<td><code>/accounts/{accountId}/credit</code></td>
<td>Credit, amount in the body</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>POST</code></td>
<td><code>/lra/accounts/{accountId}/debit</code></td>
<td>Reserve a debit, <code>@LRA(MANDATORY)</code></td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>POST</code></td>
<td><code>/lra/accounts/{accountId}/credit</code></td>
<td>Reserve a credit, <code>@LRA(MANDATORY)</code></td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>GET</code></td>
<td><code>/lra/accounts/{accountId}/availability</code></td>
<td>Balance, held and available amounts</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>PUT</code></td>
<td><code>/lra/accounts/complete</code></td>
<td><code>@Complete</code> callback</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>PUT</code></td>
<td><code>/lra/accounts/compensate</code></td>
<td><code>@Compensate</code> callback</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>GET</code></td>
<td><code>/lra/accounts/status</code></td>
<td><code>@Status</code> callback</td>
</tr>
<tr>
<td><code>account</code> (8081)</td>
<td><code>DELETE</code></td>
<td><code>/lra/accounts/forget</code></td>
<td><code>@Forget</code> callback</td>
</tr>
<tr>
<td><code>transfer</code> (8080)</td>
<td><code>POST</code></td>
<td><code>/xfers</code></td>
<td>Transfer, in one 2PC transaction</td>
</tr>
<tr>
<td><code>transfer</code> (8080)</td>
<td><code>GET</code></td>
<td><code>/xfers</code></td>
<td>List the transfer log</td>
</tr>
<tr>
<td><code>transfer</code> (8080)</td>
<td><code>GET</code></td>
<td><code>/xfers/{transferId}</code></td>
<td>Read one transfer</td>
</tr>
<tr>
<td><code>transfer</code> (8080)</td>
<td><code>PUT</code></td>
<td><code>/xfers/{transferId}</code></td>
<td>Update one transfer</td>
</tr>
<tr>
<td><code>transfer</code> (8080)</td>
<td><code>DELETE</code></td>
<td><code>/xfers/{transferId}</code></td>
<td>Delete one transfer</td>
</tr>
<tr>
<td><code>transfer-lra</code> (8090)</td>
<td><code>POST</code></td>
<td><code>/xfers</code></td>
<td>Transfer, as a saga, <code>@LRA(REQUIRED)</code></td>
</tr>
<tr>
<td><code>transfer-lra</code> (8090)</td>
<td><code>GET</code></td>
<td><code>/xfers</code></td>
<td>List the transfer log</td>
</tr>
<tr>
<td><code>transfer-lra</code> (8090)</td>
<td><code>GET</code></td>
<td><code>/xfers/{transferId}</code></td>
<td>Read one transfer</td>
</tr>
<tr>
<td><code>transfer-lra</code> (8090)</td>
<td><code>PUT</code></td>
<td><code>/xfers/{transferId}</code></td>
<td>Update one transfer</td>
</tr>
<tr>
<td><code>transfer-lra</code> (8090)</td>
<td><code>DELETE</code></td>
<td><code>/xfers/{transferId}</code></td>
<td>Delete one transfer</td>
</tr>
<tr>
<td><code>transfer-lra</code> (8090)</td>
<td><code>PUT</code></td>
<td><code>/xfers/lra/complete</code></td>
<td><code>@Complete</code> callback</td>
</tr>
<tr>
<td><code>transfer-lra</code> (8090)</td>
<td><code>PUT</code></td>
<td><code>/xfers/lra/compensate</code></td>
<td><code>@Compensate</code> callback</td>
</tr>
<tr>
<td><code>transfer-lra</code> (8090)</td>
<td><code>GET</code></td>
<td><code>/xfers/lra/status</code></td>
<td><code>@Status</code> callback</td>
</tr>
<tr>
<td><code>transfer-lra</code> (8090)</td>
<td><code>DELETE</code></td>
<td><code>/xfers/lra/forget</code></td>
<td><code>@Forget</code> callback</td>
</tr>
</tbody></table>
<p>Two things are worth reading off the table. The two transfer services present the same <code>POST /xfers</code> contract, taking the same request body of <code>{sourceAccountId, destinationAccountId, amount, currency}</code>, which is what allows a single test class to exercise both. And the account service's participant API sits under its own path prefix instead of altering the existing endpoints, which is why the saga work left the original account tests untouched.</p>
<h3>Build &amp; test</h3>
<p>Integration tests use Quarkus Dev Services (Testcontainers), so a running Docker daemon is required. No manual database setup is needed. Each service seeds its own data in dev/test profiles, on the behalf of the <code>import.sql</code> file for <code>account</code> and of the <code>import-accounts.sql</code> for <code>transfer</code>. In the <code>prod</code> profile the account service owns the <code>accounts</code> schema and no generation or seeding happens.</p>
<p>The following command runs the integration tests:</p>
<pre><code class="language-bash">mvn clean verify
</code></pre>
<p>Here is the list of the integration tests provided with the project:</p>
<ul>
<li><code>AbstractMoneyTransferContractIT</code> (transfer-tck): this is an abstract class serving as a superclass for all the integration tests. It defines the shared scenarios: happy path, insufficient funds, unknown account, listing and deletion. Assertions are on deltas, and the balance/count probes are abstract, because the XA service can read the databases directly while the saga service can only get them by calling the API over HTTP. Failure paths assert the response body as well as the status. Both stacks must return the business error rather than transaction plumbing, which a status-only assertion would not catch.</li>
<li><code>MoneyTransferIT</code> (transfer): the contract against XA, with repository-based probes.</li>
<li><code>MoneyTransferSagaIT</code> (transfer-lra): the contract against LRA, with HTTP probes, plus saga-only assertions about the <code>COMPENSATED</code> audit row and released reservations.</li>
<li><code>AccountResourceIT</code> (account): account CRUD, debit/credit, 404 on unknown account, and rejection of overdrafts and invalid amounts.</li>
</ul>
<h3>Run the full stack</h3>
<p>In order to run the full stack, production like, proceed as follows:</p>
<pre><code class="language-bash"># Build the container images (container-image.build=true is enabled)
mvn clean package
docker compose up -d
</code></pre>
<p><code>docker-compose.yaml</code> starts the whole comparison:</p>
<table>
<thead>
<tr>
<th>Service</th>
<th>Port</th>
<th>Role</th>
</tr>
</thead>
<tbody><tr>
<td><code>accounts-db</code></td>
<td>5432</td>
<td>Accounts, <code>max_prepared_transactions=100</code> for XA</td>
</tr>
<tr>
<td><code>xfers-db</code></td>
<td>5433</td>
<td>XA transfer log, <code>max_prepared_transactions=100</code></td>
</tr>
<tr>
<td><code>xfers-lra-db</code></td>
<td>5434</td>
<td>Saga transfer log (no XA needed)</td>
</tr>
<tr>
<td><code>lra-coordinator</code></td>
<td>50000</td>
<td><code>quay.io/jbosstm/lra-coordinator</code></td>
</tr>
<tr>
<td><code>account</code></td>
<td>8081</td>
<td>CRUD + LRA participant</td>
</tr>
<tr>
<td><code>transfer</code></td>
<td>8080</td>
<td>XA/2PC</td>
</tr>
<tr>
<td><code>transfer-lra</code></td>
<td>8090</td>
<td>Saga/LRA</td>
</tr>
</tbody></table>
<p>Both transfer services run against the same accounts, so you can drive the same transfer through each and compare:</p>
<pre><code class="language-bash">BODY='{"sourceAccountId":"ACC1","destinationAccountId":"ACC2","amount":10.00,"currency":"EUR"}'
curl -s -XPOST -H 'Content-Type: application/json' -d "$BODY" http://localhost:8080/xfers  # XA
curl -s -XPOST -H 'Content-Type: application/json' -d "$BODY" http://localhost:8090/xfers  # Saga
curl -s http://localhost:8081/lra/accounts/ACC1/availability                                # reservations
</code></pre>
<p>Note <code>QUARKUS_LRA_BASE_URI</code> on the two participants: it is the address the coordinator uses to call them back, and without it a participant advertises a URL that is only meaningful from its own side of the network.</p>
<p>A Swagger interface is also available with each API, as explained at §11 Endpoints. Additionally, the smoke test script <code>test-all.sh</code> is a very convenient way to make sure to cover all the test case possible combinations. Here below is an example of how to run it:</p>
<pre><code class="language-bash">$ docker compose up -d
$ ./test-all.sh

=== Account API - http://localhost:8081/accounts ===
PASS POST /accounts (create ACC90, 1000.00) -&gt; 201
PASS POST /accounts (create ACC91, 0.00) -&gt; 201
PASS POST /accounts (create ACC92, 10.00) -&gt; 201
PASS GET /accounts/ACC90 -&gt; 200
PASS balance(ACC90) == 1000.00
PASS GET /accounts (list) -&gt; 200
PASS PUT /accounts/ACC90 (rename owner) -&gt; 200
PASS GET /accounts/ACC90 (confirm rename) -&gt; 200
PASS customerName updated
PASS POST /accounts/ACC90/credit (50.00) -&gt; 200
PASS balance(ACC90) == 1050.00
PASS POST /accounts/ACC90/debit (200.00) -&gt; 200
PASS balance(ACC90) == 850.00

=== Account API - negative cases ===
PASS POST credit (-1.00) rejected -&gt; 400
PASS POST debit (0.00) rejected -&gt; 400
PASS POST debit (999999.00) insufficient funds -&gt; 400
PASS GET /accounts/NOSUCH -&gt; 404
PASS POST credit on unknown account -&gt; 404
PASS POST credit without Content-Type -&gt; 415
PASS balance(ACC90) == 850.00
PASS DELETE /accounts/ACC92 -&gt; 204
PASS GET deleted account -&gt; 404
PASS DELETE already-deleted account -&gt; 404

=== Account LRA participant API - http://localhost:8081/lra/accounts ===
PASS GET /lra/accounts/ACC90/availability -&gt; 200
PASS availability exposes balance/held/available
PASS POST /lra/accounts/ACC90/debit without LRA context -&gt; 412
PASS POST /lra/accounts/ACC90/credit without LRA context -&gt; 412
PASS balance(ACC90) == 850.00

=== XA Transfer API (2PC) - http://localhost:8080/xfers ===
PASS POST /xfers (ACC90 -&gt; ACC91, 100.00) -&gt; 200
PASS transferId returned: raizmjf
PASS balance(ACC90) == 750.00
PASS balance(ACC91) == 100.00
PASS GET /xfers/raizmjf -&gt; 200
PASS GET /xfers (list) -&gt; 200
PASS PUT /xfers/raizmjf (currency -&gt; USD) -&gt; 200

=== XA Transfer API - negative cases (nothing must move) ===
PASS POST /xfers insufficient funds -&gt; 400
PASS POST /xfers negative amount -&gt; 400
PASS POST /xfers unknown source -&gt; 404
PASS POST /xfers unknown destination -&gt; 404
PASS balance(ACC90) == 750.00
PASS balance(ACC91) == 100.00
PASS GET /xfers/NOSUCH -&gt; 404
PASS DELETE /xfers/raizmjf -&gt; 204
PASS GET deleted transfer -&gt; 404

=== Saga Transfer API (LRA) - http://localhost:8090/xfers ===
PASS POST /xfers (ACC90 -&gt; ACC91, 25.00) -&gt; 200
PASS transferId returned: etmlebm
PASS balance(ACC90) == 725.00
PASS balance(ACC91) == 125.00
PASS GET /xfers/etmlebm -&gt; 200
PASS GET /xfers (list, includes compensated) -&gt; 200
PASS @Complete flipped the transfer to COMPLETED

=== Saga Transfer API - cancellation and compensation ===
PASS POST /xfers insufficient funds (saga cancels) -&gt; 400
PASS balance(ACC90) == 725.00
PASS balance(ACC91) == 125.00
PASS @Compensate logged the cancelled transfer as COMPENSATED
PASS POST /xfers unknown destination (saga cancels) -&gt; 404
PASS balance(ACC90) == 725.00
PASS GET availability after settled sagas -&gt; 200
PASS held == 0 (no reservation left dangling)
PASS PUT /xfers/etmlebm (currency -&gt; USD) -&gt; 200
PASS GET /xfers/NOSUCH -&gt; 404
PASS DELETE /xfers/etmlebm -&gt; 204
PASS GET deleted transfer -&gt; 404

=== Saga participant callbacks - @Status and @Forget (transfer-lra) ===
PASS coordinator started LRA: http://lra-coordinator:8080/lra-coordinator/0_ffffac120002_a03b_6ad35817_1ed
PASS POST /xfers with an externally started LRA -&gt; 412
PASS GET /xfers/lra/status (@Status) -&gt; 200
PASS @Status reports Compensated for the cancelled LRA
PASS balance(ACC90) moved by 0 (now 725.00)
PASS DELETE /xfers/lra/forget (@Forget) -&gt; 200
PASS GET /xfers/lra/status after @Forget -&gt; 404
PASS @Forget kept the transfer, only dropped its LRA id

=== Account LRA participant API - driving a saga by hand ===
PASS coordinator started LRA: http://lra-coordinator:8080/lra-coordinator/0_ffffac120002_a03b_6ad35817_1f2
PASS POST /lra/accounts/ACC90/debit (40.00, in LRA) -&gt; 200
PASS balance(ACC90) moved by 0 (now 725.00)
PASS held(ACC90) moved by 40.00 (now 40.00)
PASS POST /lra/accounts/ACC91/credit (40.00, in LRA) -&gt; 200
PASS balance(ACC91) moved by 0 (now 125.00)
PASS coordinator closed the LRA -&gt; 200
PASS balance(ACC90) moved by -40.00 (now 685.00)
PASS balance(ACC91) moved by 40.00 (now 165.00)
PASS held(ACC90) moved by 0 (now 0)

=== Account LRA participant API - cancelling a saga by hand ===
PASS coordinator started LRA: http://lra-coordinator:8080/lra-coordinator/0_ffffac120002_a03b_6ad35817_1f7
PASS POST /lra/accounts/ACC90/debit (15.00, in LRA) -&gt; 200
PASS held(ACC90) moved by 15.00 (now 15.00)
PASS coordinator cancelled the LRA -&gt; 200
PASS balance(ACC90) moved by 0 (now 685.00)
PASS held(ACC90) moved by 0 (now 0)

=== Summary ===
87 passed, 0 failed
</code></pre>
<h2>12. Comparison</h2>
<p>The attached GitHub repository contains a multi-module Maven project with two implementations. The first uses JTA and XA to obtain a two-phase commit, and is contained entirely in the <code>transfer</code> module. The second uses MicroProfile LRA, and is necessarily spread across two modules: <code>transfer-lra</code> orchestrates the saga, while <code>account</code> takes part in it. That difference in shape is not an accident of packaging. A JTA coordinator that enlists resource managers directly can live in a single module, the <code>transfer</code> one, whereas a saga cannot exist unless its participants are reachable and callable, hence the necessity for it to live in two modules, <code>transfer-lra</code> and <code>account</code>.</p>
<p>Both implementations satisfy the same test contract. The following differences are therefore differences of mechanism and of consequence, not of capability.</p>
<table>
<thead>
<tr>
<th>Dimension</th>
<th>XA and two-phase commit</th>
<th>Saga and LRA</th>
</tr>
</thead>
<tbody><tr>
<td>Coordinator</td>
<td>Embedded in the application process</td>
<td>Separate process, must call participants back</td>
</tr>
<tr>
<td>Data ownership</td>
<td>Coordinator holds the resource managers, so services share a database</td>
<td>Each service retains its own data</td>
</tr>
<tr>
<td>Isolation</td>
<td>Complete; no intermediate state is observable</td>
<td>Absent by design; a reservation is observable while in flight</td>
</tr>
<tr>
<td>Failure</td>
<td>Rollback leaves no trace whatsoever</td>
<td>Leaves a record that the operation was attempted and undone</td>
</tr>
<tr>
<td>Locks</td>
<td>Held between prepare and commit</td>
<td>None held across the action</td>
</tr>
<tr>
<td>Availability</td>
<td>Participants block if the coordinator fails while in doubt</td>
<td>Participants remain available; completion may occur later</td>
</tr>
<tr>
<td>Location of difficulty</td>
<td>Infrastructure, written once</td>
<td>Application code, written for each operation</td>
</tr>
<tr>
<td>Failure of the undo</td>
<td>Not applicable; nothing was committed</td>
<td>Possible, unless reservations are used</td>
</tr>
</tbody></table>
<p>Two entries deserve comment.</p>
<p>The row concerning failure is frequently presented as an advantage of 2PC on the grounds that the rollbacks are clean. It may equally be regarded as a loss of information. A cancelled saga records that a transfer was attempted and subsequently undone, which is an audit trail that a rollback cannot produce because the rows were never committed. Whether this constitutes an advantage depends entirely on whether the business is required to account for attempts as well as for outcomes, and this is a question for the domain rather than for the architecture.</p>
<p>The row concerning the location of difficulty is, in my opinion, the one most often omitted from comparisons. 2PC is difficult once, in infrastructure maintained by specialists. Sagas are difficult repeatedly, in application code and this argument is important.</p>
<p>The correct conclusion is not that one approach supersedes the other. It is that the choice is determined by whether the resource managers can be co-located under a single coordinator. If they can, 2PC provides a stronger guarantee for less application code. If they cannot, because the services are genuinely independent or the resources do not support XA, then a saga is not the inferior option but the only option, and the engineering effort should be directed at implementing it correctly rather than at regretting the atomicity that was never available.</p>
<h2>13. The Present and the Future</h2>
<p>Two-phase commit is not disappearing. It remains appropriate wherever resources can be co-located, and a significant proportion of enterprise data continues to reside in exactly such arrangements. Reports of its obsolescence generally originate from contexts in which it was never applicable.</p>
<p>Sagas are becoming ordinary. What is changing is the level of abstraction at which they are expressed. Handwritten orchestration is giving way to specified protocols such as LRA, to workflow engines that record the state of long-running processes durably, and to durable execution platforms in which the compensation logic is expressed as ordinary code. The direction of travel is consistent: the difficulty is being moved back out of application code and into infrastructure, which is where the industry placed it in the first place, some thirty years ago, and where it appears to belong.</p>
<p>Two developments merit attention. The first is the growing use of the outbox pattern with event streaming, which achieves atomicity between a database change and a message by writing both to the same database and publishing asynchronously. This is neither 2PC nor a saga in the classical sense, and for many integration problems it is a better answer than either. The second is the increasing availability of formal verification tools for distributed protocols, which offers some prospect that compensation logic might eventually be checked rather than merely reviewed.</p>
<p>The underlying tension, however, is not a matter of technology and will not be resolved by these developments. Atomicity across independent parties requires either that they transfer autonomy to a coordinator or that they accept observable intermediate states. The FLP (<em>Fischer, Lynch and Paterson</em>) result and its relatives indicate that no implementation will escape this choice. What improves is the quality of the tools with which each side of the choice may be pursued, and the clarity with which the choice is presented to the practitioners.</p>
<p>The most costly systems are not those that chose two-phase commit, nor those that chose sagas, but those that believed they had chosen the former while in fact operating the latter, without compensations.</p>
<hr />
<h2>References and Further Reading</h2>
<ul>
<li>Gray, J. <em>Notes on Data Base Operating Systems</em>, 1978.</li>
<li>Fischer, M., Lynch, N., Paterson, M. <em>Impossibility of Distributed Consensus with One Faulty Process</em>, Journal of the ACM, 1985.</li>
<li>Garcia-Molina, H., Salem, K. <em>Sagas</em>, ACM SIGMOD, 1987.</li>
<li>X/Open. <em>Distributed Transaction Processing: The XA Specification</em>.</li>
<li>Object Management Group. <em>Object Transaction Service</em>.</li>
<li>Eclipse MicroProfile. <em>MicroProfile LRA Specification</em>.</li>
<li>The accompanying source code, <a href="https://github.com/nicolasduminil/quarkus-distributed-tx"><code>quarkus-distributed-tx</code></a>, containing both implementations, the shared contract test suite and a Docker Compose deployment that runs the two stacks side by side.</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[RDBMS and Kafka Distributed Transactions with Quarkus]]></title><description><![CDATA[Apache Kafka supports transactions, and many developers who use Kafka daily would be unable to state precisely what those transactions cover. The term is…]]></description><link>https://nicolasduminil.hashnode.dev/rdbms-and-kafka-distributed-transactions-with-quarkus</link><guid isPermaLink="true">https://nicolasduminil.hashnode.dev/rdbms-and-kafka-distributed-transactions-with-quarkus</guid><dc:creator><![CDATA[nicolasduminil]]></dc:creator><pubDate>Thu, 19 Nov 2026 14:43:50 GMT</pubDate><content:encoded><![CDATA[<h2>Abstract</h2>
<p>Apache Kafka supports transactions, and many developers who use Kafka daily would be unable to state precisely what those transactions cover. The term is familiar from relational databases, where a transaction groups several writes into a single atomic outcome. In enterprise grade applications, the same outcome might be extended from databases to message brokers. For example, one of the most common business case is having transactional operations spanning databases like PostgreSQL, Oracle, etc. and message brokers like ActiveMQ, Artemis, etc.</p>
<p>But Kafka isn't a message broker like the others and, as opposed to classical ones, it doesn't provide any XA adapter that would allow it to participate in 2PC transactions. However, implementing transactional operations enlisting database updates and Kafka messaging as a single work unit is possible and this article demonstrates how.</p>
<p>It establishes what a Kafka transaction actually contains, explains the protocol by which it reaches its outcome, and then measures how much atomicity becomes available when a Kafka transaction is chained around a database transaction in the same handler. The working implementation is the <code>transfer-kafka</code> module of the <a href="https://github.com/nicolasduminil/quarkus-distributed-tx"><code>quarkus-distributed-tx</code></a> repository, where it joins an XA and a saga implementation of the same money transfer use case, all three exposing the same REST contract and exercised by the same shared test suite.</p>
<p>The article is illustrated by a use case implementating a money transfer application. It manages standing orders between two accounts, by debiting the source and crediting the destination account, and records the movement as a transfer. It exposes a REST contract and satisfies an abstract test class.</p>
<hr />
<h2>1. The Question This Article Answers</h2>
<p>The scenario is ordinary. A service consumes a message describing a money transfer, debits one account, credits another, records the transfer, and publishes an event announcing the result. Three kinds of state change occur: rows are written in PostgreSQL, a record is produced to a Kafka output topic, and the consumer position on the input topic advances so that the message is considered handled.</p>
<p>The question is what happens to those databases and topics when something interrupts the sequence. A developer accustomed to the X/Open Distributed Transaction Processing model will expect a transaction manager to enlist both the database and the broker as resources under one coordinator. However, as already mentioned, Apache Kafka isn't a message broker, like ActiveMQ, Artemis, etc., but a distributed log, and this changes everything. Nevertheless, Apache Kafka is designed to participate in a transaction protocol of its own design, with its own coordinator, its own log and its own commit decision, and that protocol is defined over the cluster.</p>
<p>Understanding the shape of the available guarantee therefore requires understanding the Kafka protocol first. Section 2 supplies that, in more detail.</p>
<h2>2. The Anatomy of a Kafka Transaction</h2>
<p>Kafka transactions were specified in <a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-98+-+Exactly+Once+Delivery+and+Transactional+Messaging">KIP-98, "Exactly Once Delivery and Transactional Messaging"</a>, and shipped in Kafka 0.11 in 2017. The specification combines two mechanisms that are frequently confused with each other, so it is worth separating them before describing either.</p>
<h3>2.1 The idempotent producer</h3>
<p>The first mechanism addresses duplication caused by producer retries. A producer that sends a record and then loses network connectivity before the acknowledgement arrives has no way to distinguish a lost record from a lost acknowledgement, so it retries, and the broker may append the record twice.</p>
<p>The idempotent producer solves this by giving each producer a numeric identifier, obtained from the broker, and by numbering every record it sends within a partition with a monotonically increasing sequence number. The broker remembers, for each producer identifier and partition, the sequence number it last accepted. A record arriving with a sequence number already seen by the broker is acknowledged and discarded. A record arriving with a gap in the sequence numbers is rejected as well. The effect is that a retry within a producer session appends exactly one record.</p>
<p>This mechanism operates per partition and per producer session. It is enabled by <code>enable.idempotence</code> proprty, and it is a prerequisite for the second mechanism.</p>
<h3>2.2 The transactional producer and the transaction coordinator</h3>
<p>The second mechanism groups several writes, possibly spanning several topics and partitions, into one atomic unit. A producer becomes transactional by being configured with a <code>transactional.id</code>, that survives restarts of the process.</p>
<p>That identifier is the key to a broker side component called the transaction coordinator. The <code>transactional.id</code> is hashed to a partition of an internal topic named <code>__transaction_state</code>, which KIP-98 calls the transaction log, and the leader of that partition acts as the coordinator for that producer. The coordinator holds the authoritative state of every transaction that producer opens, and it writes each state change durably into the transaction log before acting on it.</p>
<p>Two consequences follow immediately. The first is that the coordinator is a Kafka broker rather than a component of the application, so the decision to commit survives the possible death of the application process. The second is that a stable <code>transactional.id</code> allows a restarted producer to be recognized as the same logical producer, which is what makes recovery possible.</p>
<p>Recognition is enforced by a producer Linux epoch that the transaction coordinator stores in the transaction log beside the producer identifier for a given <code>transactional.id</code>.</p>
<p>Each transaction initiation, materialized by a call to <code>initTransactions()</code>, increments the stored epoch and returns the new value to the producer that caused the increment. Every request that producer issues afterward carries the producer identifier together with that epoch, whether the request produces records, adds partitions to the transaction, commits offsets or ends the transaction. A broker receiving a request whose epoch is lower than the value it holds refuses that request with an <code>InvalidProducerEpoch</code> error.</p>
<p>The purpose is to resolve the case in which two processes believe themselves to be the same producer. A service may be paused by a long garbage collection, or separated from the cluster by a network partition, while the platform running it concludes that it has failed and starts a replacement configured with the same <code>transactional.id</code>. Both processes are then live, and the older one remains unaware that it has been replaced. KIP-98 describes the remedy plainly, stating that the epoch is bumped "so that any previous zombie instance of the producer is fenced off". Because the replacement initialized later, it holds the higher epoch, and the broker refuses everything the older process sends. Authority is therefore determined by the broker, which observes both processes.</p>
<p>Developers familiar with optimistic locking will recognize the shape of the mechanism. The epoch plays the part that a version column plays in a JPA entity, where an update arriving with a stale version is refused rather than applied. The same initialization also resolves whatever transaction the previous incarnation left open, aborting it when it had yet to be decided.</p>
<h3>2.3 The lifecycle, step by step</h3>
<p>The protocol that reaches the outcome is itself a two phase commit, executed inside Kafka between the coordinator and the partition leaders. The sequence below follows the data flow specified in KIP-98.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6afb2ac0836d162959b63177/53dc3299-dbd4-4320-a43b-21cf9d8d694d.png" alt="Sequence diagram of a Kafka transaction from initialisation to commit" style="display:block;margin:0 auto" />

<p>Reading that sequence as a two phase commit makes its structure clear. The <code>EndTxn</code> request is the application asking for an outcome. The write of <code>PREPARE_COMMIT</code> to the transaction log is the point at which the decision becomes durable and irrevocable, exactly as a transaction manager writing its decision to an object store makes an XA outcome irrevocable. The markers written afterward are the second phase, instructing each participant to make the decision visible. The final write of <code>COMMITTED</code> records that the second phase completed.</p>
<p>An abort follows the same shape with <code>PREPARE_ABORT</code> and abort markers in place of their commit counterparts.</p>
<h3>2.4 Control markers and the read_committed isolation level</h3>
<p>The records a transaction produces are appended to their partitions as the transaction proceeds, before any outcome is known. Visibility, rather than placement, is what the outcome governs.</p>
<p>The mechanism is a control message, which KIP-98 defines as a special message "written to user topics, processed by clients, but never exposed to users". At commit or abort time the coordinator instructs each participating partition leader to append such a marker, carrying the producer identifier and a type of commit or abort. Markers may be written only through the internal <code>WriteTxnMarkers</code> request, since the specification states that "the writing of control messages is not permitted through the Produce API".</p>
<p>A consumer configured with <code>isolation.level=read_committed</code> uses those markers to decide what to deliver to the application. It reads only as far as the Last Stable Offset, which is the position beyond which a transaction remains undecided, and it discards records belonging to transactions whose marker says abort. The fetch response carries a list of aborted transactions so the consumer can discard that data directly.</p>
<p>The practical consequence is that a record produced inside a transaction that later aborts is physically present in the log and is withheld from every <code>read_committed</code> consumer. The default isolation level is <code>read_uncommitted</code>, under which such records are delivered, so the guarantee requires the setting to be made deliberately on the consuming side.</p>
<h3>2.5 Consumer offsets as a transactional resource</h3>
<p>A Kafka transaction can include the commit of consumer offsets. The internal topic <code>__consumer_offsets</code> is an ordinary Kafka topic, and a transactional producer may write to it as a participant in its transaction, through <code>sendOffsetsToTransaction(...)</code>. KIP-98 states the effect directly: "The consumed offsets are not visible externally until the transaction is committed." When the transaction commits, a marker is written to the offsets partition as well, the group coordinator materializes the offsets, and the consumer position advances. When the transaction aborts, the offsets are discarded and the consumer position remains where it was.</p>
<p>A consumer whose position has not advanced receives the same records again on its next fetch. Aborting a transaction therefore returns the input to the state it occupied before the handler ran. This is the property which makes a Kafka transaction to support operations that genuinely resemble rollbacks.</p>
<h3>2.6 The scope of the guarantee</h3>
<p>A Kafka transaction covers exactly three categories of state, all of them inside the Kafka cluster:</p>
<ul>
<li>records appended to data partitions</li>
<li>consumer offsets written to <code>__consumer_offsets</code></li>
<li>the transaction state itself</li>
</ul>
<p>Within that boundary the guarantee is strong, durable and coordinated by a broker that survives the application process.</p>
<h2>3. The Boundary of the Kafka Protocol</h2>
<p>The X/Open model achieves atomicity across heterogeneous resources by defining a common interface, XA, that every participating resource manager implements, and by placing a transaction manager above them to drive the protocol. A JDBC datasource configured with <code>jdbc.transactions=xa</code> supplies connections whose <code>XAResource</code> the transaction manager enlists, and the manager then calls <code>prepare</code> and <code>commit</code> on that resource alongside every other branch.</p>
<p>Kafka reaches its outcome through the protocol described in section 2, in which the coordinator is a broker, the participants are partition leaders, and the decision is recorded in a Kafka topic. The client API that exposes this protocol is the producer API, with <code>beginTransaction(...)</code>, <code>commitTransaction(...)</code> and <code>abortTransaction(...)</code>. An external transaction manager has no interface through which to make Kafka a branch of its own transaction, and the Kafka coordinator has no interface through which to make a database a participant in its own.</p>
<p>This arrangement is a design decision rather than an omission. KIP-98 aimed at a protocol that performs well at Kafka's throughput and remains available under broker failure, and a generic cross resource protocol would have imposed costs that the stream processing use cases driving the design did not require.</p>
<p>The practical conclusion for an application performing transactional database and Kafka operations is therefore specific. Two coordinators exist. The first is the JTA transaction manager, which is Narayana in the case of Quarkus, running inside the application process and authoritative over the XA resources enlisted in its transaction. In our project these XA resources are the two PostgreSQL databases. The second is the Kafka transaction coordinator, which is the broker leading the <code>__transaction_state</code> partition selected for the configured <code>transactional.id</code>, authoritative over the produced records, the consumer offsets and the transaction state itself, which are the categories section 2.6 enumerates. Each decides the outcome of its own resources alone, and the application decides how to arrange work between them. That arrangement is the subject of the remainder of this article.</p>
<h2>4. Choosing the Direction: Consume, Write, Produce</h2>
<p>Two arrangements are available, and the choice between them determines how much of the guarantee survives.</p>
<p>In the outbound arrangement the application writes to the database, publishes an event, and the Kafka transaction covers only the produced record. The two resources reach their outcomes through two separate commits, taken one after the other, and the interval between them is a window in which exactly one of the two commits has taken effect. An interruption inside that window leaves the resource that committed first in a status that isn't propagated to the other. Where the database commits first, the window ends with a committed row and its associated event unpublished, so every downstream consumer stays unaware of a money transfer that the database considers complete. Where the Kafka transaction commits first, the interruption finds the database transaction still open, and a transaction that remains open when its client connection ends is discarded by the server. The window therefore ends with a published event that consumers may already have acted upon, concerning a money transfer that the database retains no record of. The second case is the more troublesome of the two, because a published event is a fact that other systems have observed and erroneously acted upon, whereas an unpublished event is a fact that a later reconciliation can still supply.</p>
<p>In the inbound arrangement the application consumes a message, writes to the database, and publishes an outcome event, committing the consumed offset inside the same Kafka transaction. Here the Kafka transaction covers a resource that can be returned to an earlier value, namely the consumer position. An abort returns the consumer to its previous position, the broker redelivers the message, and the handler runs again.</p>
<p>The inbound arrangement is therefore the strongest of the two, for a reason that can be stated precisely. Its worst case is the repetition of work, which an idempotent handler absorbs, whereas the outbound worst case is the publication of an event that cannot be retracted. The implementation that follows uses the inbound arrangement.</p>
<h2>5. The Implementation</h2>
<h3>5.1 The project the module joins</h3>
<p>The module described here belongs to a repository that implements one use case three times. The use case is a money transfer between two accounts, which debits the source account, credits the destination account and records the movement as a transfer. The three implementations expose the same REST contract, satisfy the same abstract test class, and differ in the manner by which they make the operation atomic.</p>
<p>The data of that use case is divided between two PostgreSQL databases. The database named <code>accounts</code> holds one row per account, carrying the balance that a debit and a credit modify. The database named <code>xfers</code> holds one row per transfer, carrying the amount, the currency, the two account identifiers and a status. The division is deliberate, because it makes a single transfer a distributed transaction before any messaging is considered. One business operation writes to two independent database servers, each with a transaction manager of its own, and the operation is correct only when both writes take effect together or both are discarded together.</p>
<p>The first implementation, which the first <a href="https://www.simplex-software.fr/posts-archive/quarkus-2pc-lra/">article</a> of this series describes, resolves that with the X/Open model. Both datasources are declared with <code>jdbc.transactions=xa</code>, which causes each connection to expose an <code>XAResource</code>, and Narayana enlists the two as branches of one global transaction and drives prepare and commit across them. The second implementation replaces the global transaction with a saga, in which each step owns a compensating action and a coordinator invokes those compensations when a later step fails. The third implementation is the subject of this article. It retains the XA arrangement for the two databases and places a Kafka transaction around it.</p>
<p>Two consequences of that inheritance govern the sections that follow. The first is that the database work of the handler is one transaction spanning two databases, so a rollback returns both of them to their previous state together, and a commit makes both sets of changes visible at the same instant. The second is that this two database transaction is itself nested inside a Kafka transaction, so the complete arrangement is a two phase commit over two relational databases chained within a scope that also covers a topic and the consumer offsets.</p>
<h3>5.2 Module layout</h3>
<p>The <code>transfer-kafka</code> module reuses the domain, the persistence layer, the transfer service and the REST contract of the XA implementation through a shared <code>transfer-core</code> module, so that the only difference between the two is the transaction strategy. It holds two XA datasources, <code>accounts</code> and <code>xfers</code>, exactly as the XA module does, which means Narayana already provides one atomic unit across both databases. The Kafka transaction is chained around that unit.</p>
<p>What the module adds is the Kafka material: a listener, a payload type, an idempotency ledger and an observer that records what a <code>read_committed</code> consumer actually receives. The idempotency ledger is the <code>PROCESSED_REQUESTS</code> table, which holds one row for each request identifier the handler has applied, and whose purpose is to make a second delivery of an already applied request harmless. It is a record of requests rather than a record of money transfers, which distinguishes it from the <code>XFERS</code> table holding the transfers themselves. Both tables reside in the datasource named <code>xfers</code>, while the balances reside in the datasource named <code>accounts</code>. Section 9 explains why the ledger is required.</p>
<h3>5.3 The listener</h3>
<p>The handler code is reproduced in the listing below.</p>
<pre><code class="language-java">@ApplicationScoped
public class TransferRequestListener
{
  @Inject
  TransferService transferService;

  @Inject
  TransferRepository transferRepository;

  @Inject
  ProcessedRequestRepository processedRequestRepository;

  @Inject
  FailureInjection failureInjection;

  @Channel("transfer-events")
  KafkaTransactions&lt;TransferEvent&gt; emitter;

  private final Map&lt;String, AtomicInteger&gt; deliveries =
    new ConcurrentHashMap&lt;&gt;();

  public Map&lt;String, Integer&gt; deliveries()
  {
    Map&lt;String, Integer&gt; snapshot = new HashMap&lt;&gt;();
    deliveries.forEach((requestId, count) -&gt;
      snapshot.put(requestId, count.get()));
    return snapshot;
  }

  public int deliveriesOf(String requestId)
  {
    AtomicInteger count = deliveries.get(requestId);
    return count == null ? 0 : count.get();
  }

  @Incoming("transfer-requests")
  @Blocking
  public Uni&lt;Void&gt; onTransferRequest(Message&lt;TransferRequest&gt; message)
  {
    String requestId = requestIdOf(message);
    deliveries.computeIfAbsent(requestId, key -&gt; new AtomicInteger())
      .incrementAndGet();
    return emitter.withTransactionAndAck(message, tx -&gt;
    {
      try
      {
        apply(requestId, message.getPayload()).ifPresent(tx::send);
        return Uni.createFrom().voidItem();
      }
      catch (RuntimeException runtimeException)
      {
        return Uni.createFrom().failure(runtimeException);
      }
    });
  }

  private Optional&lt;TransferEvent&gt; apply(String requestId,
    TransferRequest request)
  {
    if (QuarkusTransaction.requiringNew()
      .call(() -&gt; processedRequestRepository.alreadyProcessed(requestId)))
      return Optional.empty();
    try
    {
      return Optional.of(complete(requestId, request));
    }
    catch (ApplicationException rejection)
    {
      return Optional.of(reject(requestId, request,
        rejection.getMessage()));
    }
  }

  private TransferEvent complete(String requestId,
    TransferRequest request)
  {
    return QuarkusTransaction.requiringNew().call(() -&gt;
    {
      TransferDto transfer = transferService.processTransfer(request);
      processedRequestRepository.record(new ProcessedRequest(
        requestId, transfer.getTransferId(), LocalDateTime.now()));
      if (failureInjection.consume(requestId))
        throw new IllegalStateException("### injected failure between "
          + "the database write and the Kafka commit");
      return TransferEvent.of(requestId, transfer);
    });
  }

  private TransferEvent reject(String requestId,
    TransferRequest request, String reason)
  {
    return QuarkusTransaction.requiringNew().call(() -&gt;
    {
      Transfer rejected = new Transfer(Common.getRandomId(),
        request.getSourceAccountId(), request.getDestinationAccountId(),
        request.getAmount(), request.getCurrency(),
        TransferStatus.REJECTED, LocalDateTime.now());
      transferRepository.createTransfer(rejected);
      processedRequestRepository.record(new ProcessedRequest(
        requestId, rejected.getTransferId(), LocalDateTime.now()));
      return TransferEvent.of(requestId, rejected.toDto(), reason);
    });
  }

  private String requestIdOf(Message&lt;TransferRequest&gt; message)
  {
    return message.getMetadata(IncomingKafkaRecordMetadata.class)
      .map(metadata -&gt; String.valueOf(metadata.getKey()))
      .orElseGet(Common::getRandomId);
  }
}
</code></pre>
<p>The five injected members cover database access, failure injection and the Kafka side of the handler. <code>TransferService</code> and <code>TransferRepository</code> are inherited from the shared <code>transfer-core</code> module, and <code>ProcessedRequestRepository</code> is declared in this module to reach the <code>PROCESSED_REQUESTS</code> table that section 9 describes, these three members being the ones through which the handler reaches the two databases. <code>FailureInjection</code> is a small application scoped bean that defines a counter through which a test requests a deterministic interruption, and section 7 explains the position at which that interruption takes effect. The <code>emitter</code> field is the Kafka side of the handler, declared as <code>KafkaTransactions&lt;TransferEvent&gt;</code> and bound by <code>@Channel</code> to the outgoing channel named <code>transfer-events</code>. That declaration is what causes Quarkus to configure a transactional producer for the channel, as section 6 shows.</p>
<p>The <code>deliveries</code> map counts the arrivals of each request identifier, and the two accessor methods publish that count so that a test may assert upon it. The count is the observable on which the demonstration of rollback rests, because an aborted transaction is established by a second delivery of the same message and the count reflects that. A <code>ConcurrentHashMap</code> holds the counters because the Kafka worker threads access the map concurrently.</p>
<p>The method <code>onTransferRequest</code> is the entry point. The annotation <code>@Incoming</code> binds it to the incoming channel named <code>transfer-requests</code>, and <code>@Blocking</code> moves its execution from the I/O thread to a worker one. This is because JDBC calls block the calling thread. The method obtains the request identifier, records the delivery, and hands the remaining work to <code>withTransactionAndAck(...)</code>.</p>
<p>That single call performs four operations. It begins a Kafka transaction, it supplies a <code>TransactionalEmitter</code> to the given function, it enlists the offset of the consumed record in the transaction, and it determines the outcome from the <code>Uni</code> the function returns. A <code>Uni</code> that completes causes the transaction to commit and the message to be acknowledged. A <code>Uni</code> that carries a failure causes the transaction to abort and the message to be negatively acknowledged.</p>
<p>The body of the function is wrapped in a <code>try</code> block whose <code>catch</code> clause converts a <code>RuntimeException</code> into a failed <code>Uni</code>. The conversion matters because the function executes inside a Mutiny pipeline, in which an exception thrown synchronously and a failure carried by the returned <code>Uni</code> reach different handlers. Returning the failure keeps the outcome on the path that <code>withTransactionAndAck(...)</code> observes. This is the path that aborts the transaction and leaves the offset uncommitted.</p>
<p>The call <code>apply(requestId, message.getPayload()).ifPresent(tx::send)</code> performs the work and publishes its outcome. The method <code>apply</code> returns an <code>Optional</code>, and <code>ifPresent(...)</code> sends an event exactly when one is present, through the <code>TransactionalEmitter</code> and therefore inside the open transaction. The empty case belongs to a request already recorded in <code>PROCESSED_REQUESTS</code>, which produces no event.</p>
<p>The method <code>apply</code> arranges the three possible outcomes of a request. It first consults the <code>PROCESSED_REQUESTS</code> table in a transaction of its own and returns an empty <code>Optional</code> when the request identifier is already present, which is the idempotent path of section 9. Otherwise, it delegates to <code>complete(...)</code>. An <code>ApplicationException</code>, which is the type the shared transfer service throws when the business refuses an operation, is caught and routed to <code>reject(...)</code>, whereas every other runtime exception leaves the method and reaches the <code>catch(...)</code> clause of the caller. That one distinction is the policy stated in section 8.</p>
<p>The method <code>complete(...)</code> performs the successful path inside one JTA transaction, begun by <code>QuarkusTransaction.requiringNew()</code>, which Narayana commits when the lambda function returns a value and rolls back when it throws. Three operations share that transaction, and they reach both databases. The call <code>transferService.processTransfer(...)</code> updates the two account rows in <code>accounts</code> and writes the transfer row in <code>xfers</code>. The row written to <code>PROCESSED_REQUESTS</code> records the request identifier together with the resulting transfer identifier, in <code>xfers</code> beside the transfer. Narayana therefore enlists two XA branches for this single transaction and drives prepare and commit across both, which is the two phase commit occurring inside a Kafka transaction. The call <code>failureInjection.consume(requestId)</code> occupies the final position, which places any injected exception before the commit and therefore within the scope that the rollback discards.</p>
<p>The method <code>reject(...)</code> writes a refused outcome, likewise in a fresh transaction. It creates a transfer row carrying the status <code>REJECTED</code> directly through the repository, and it records the request identifier in <code>PROCESSED_REQUESTS</code> so that a redelivery of a refused request produces a single rejection event. The reason supplied by the exception is copied into the event, which allows a consumer to learn the ground on which a transfer was refused as well as the fact of the refusal.</p>
<p>The method <code>requestIdOf(...)</code> reads the identifier from the Kafka record key through <code>IncomingKafkaRecordMetadata</code>, and generates one when a record arrives without a key. The key is therefore the name under which a logical request is known across its deliveries, a property to which section 9 returns.</p>
<h3>5.4 The configuration</h3>
<p>The incoming channel carries two settings whose purpose is frequently misread.</p>
<pre><code class="language-properties">mp.messaging.incoming.transfer-requests.commit-strategy=ignore
mp.messaging.incoming.transfer-requests.failure-strategy=ignore
</code></pre>
<p>The first instructs SmallRye Reactive Messaging to leave offset commits entirely to the transaction. Any other commit strategy would advance the consumer position independently of the transaction outcome.</p>
<p>The second instructs the channel to let the transaction decide what happens after a failure. A message whose processing succeeds is acknowledged, and a message whose processing fails is negatively acknowledged. This operation is named "nacking". Under the ignore failure strategy a negatively acknowledged message causes the consumer to reset to the last committed offsets and to resume from there, which is the redelivery described in section 7. The log line the application emits at that moment reads as follows.</p>
<pre><code class="language-plaintext">SRMSG18204: A message sent to channel `transfer-requests` has been nacked,
            ignored failure is: ### injected failure between the database
            write and the Kafka commit
</code></pre>
<p>The producer side requires no explicit client configuration, because Quarkus recognises a <code>KafkaTransactions</code> channel and supplies the necessary settings itself.</p>
<pre><code class="language-plaintext">Transactional producer detected for channel 'transfer-events', setting
following default config values:
  mp.messaging.outgoing.transfer-events.transactional.id=
      ${quarkus.application.name}-${channelName}
  mp.messaging.outgoing.transfer-events.enable.idempotence=true
  mp.messaging.outgoing.transfer-events.acks=all
</code></pre>
<p>Those three settings are precisely defining a stable transactional identifier, the idempotent producer underneath it, and the full acknowledgement so that a committed record is durable on every in sync replica.</p>
<p>One further setting requires explanation. Quarkus Dev Services starts the broker in a container, and it offers a choice among several providers. Apache Kafka is available in two forms, a conventional build running on the Java virtual machine and a build compiled ahead of time with GraalVM, which starts faster and is the default in Quarkus 3.37. Redpanda is an independent implementation of the Kafka protocol, written in C++ and distributed as a single binary, which presents the same client API over a different internal architecture. Strimzi is the project that operates Apache Kafka on Kubernetes, and the container images it publishes for testing hold a genuine Apache Kafka broker running on the Java virtual machine.</p>
<p>The choice among the above mentioned providers matters for one reason. The Quarkus documentation states that <a href="https://quarkus.io/guides/kafka-dev-services/">Redpanda transactions do not support exactly once processing</a>, and it records the absence of KIP-447 and KIP-360. KIP-447, titled "Producer scalability for exactly once semantics", is the proposal through which a transactional producer commits consumer offsets while carrying the metadata of its consumer group, which allows the broker to fence a member that has left the group. That commit is the mechanism section 2.5 described and the one on which this implementation relies. KIP-360, titled "Improve reliability of idempotent/transactional producer", governs the recovery of a producer whose identifier the broker has discarded.</p>
<p>The module therefore names its provider explicitly, rather than inheriting a default value that has changed across Quarkus versions.</p>
<pre><code class="language-properties">quarkus.kafka.devservices.provider=upstream-kafka-native
</code></pre>
<p>The test run confirms the choice, reporting the image <code>apache/kafka-native:4.2.0</code>.</p>
<h3>5.5 The nesting order</h3>
<p>The Kafka transaction is the outer one, and the inner one is the JTA transaction that spans the two databases. That ordering is deliberate, and reversing it would change the guarantee.</p>
<p>Placing Kafka outside means the consumed offset belongs to the transaction that is decided last, so the input remains replayable until everything else has succeeded. The inner transaction commits first, which through the X/Open protocol makes the changes in <code>accounts</code> and in <code>xfers</code> visible at one instant, and it does so within the lifetime of the Kafka transaction. The Kafka transaction then commits the produced event together with the offset.</p>
<p>The complete arrangement therefore nests three levels. The two relational databases form the branches that Narayana enlists and that constitute one JTA transaction. That unit of work is entirely contained in one Kafka transaction covering the produced event and the consumed offset. Atomicity within each level is guaranteed by the protocol.</p>
<h2>6. The Committing Path</h2>
<p>The ordinary case proceeds as follows.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6afb2ac0836d162959b63177/4b9ffd8b-4a84-4603-8a63-2a1176a8cbd1.png" alt="Sequence diagram of the committing path" style="display:block;margin:0 auto" />

<p>Four observable facts follow. The balances have moved. The transfer row is present, and so is the <code>PROCESSED_REQUESTS</code> row naming the request. A consumer reading with <code>isolation.level=read_committed</code> has received the outcome event. The consumer position has advanced, so the message is delivered once.</p>
<h2>7. The Rolling Back Path</h2>
<p>An interruption occurring while the Kafka transaction is still open produces the sequence below. In the demonstration the interruption is injected deterministically, so that the behavior is asserted in a test rather than observed by chance.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6afb2ac0836d162959b63177/d3799c4c-122e-4a99-bb38-acaa5d62187a.png" alt="Sequence diagram of the rolling back path" style="display:block;margin:0 auto" />

<p>The failure is injected on one delivery only. A test calls <code>armOnce</code> with the request identifier, which sets a counter held against that identifier to one. The method <code>complete</code> then calls <code>failureInjection.consume(requestId)</code>, which decrements the counter and returns true while its value remains positive. The failure therefore occurs on the first delivery of the record, and every subsequent delivery of the same record proceeds normally. The demonstration consists of two deliveries, and the two are described in turn.</p>
<p>The position of the injected failure is what makes the first delivery a rollback of both resources. The exception is thrown inside the JTA transaction, after the balances have been updated in the <code>accounts</code> database and the transfer row together with the <code>PROCESSED_REQUESTS</code> row have been written to the <code>xfers</code> database, and before Narayana commits. All three writes therefore belong to a transaction that rolls back, and because both datasources are XA resources of that single transaction, the two databases roll back together. The same exception then leaves the function given to <code>withTransactionAndAck(...)</code> as a failed <code>Uni</code>, which aborts the Kafka transaction, and the abort discards the produced event and the consumed offset together. The consumer position consequently remains where it was, and the broker delivers the same record a second time.</p>
<p>On the second delivery the counter stands at zero, so <code>failureInjection.consume(requestId)</code> returns false and no exception is thrown, and <code>PROCESSED_REQUESTS</code> holds no row for the request, because the first attempt committed nothing. The delivery therefore updates the two PosrgreSQL databases, records the request identifier, publishes the event and commits, exactly as section 6 described.</p>
<p>Four facts are observable once the sequence has settled. The balances differ from their initial values by one amount rather than by two. One transfer row exists. One outcome event carrying the status <code>COMPLETED</code> is visible to a consumer reading with <code>isolation.level=read_committed</code>. The listener counted two deliveries of the request identifier.</p>
<p>The third and fourth facts taken together are what establish the rollback. Consider the alternative in which the database work of the first delivery had been retained rather than discarded. <code>PROCESSED_REQUESTS</code> would then hold a row for the request identifier, the second delivery would be recognized as a replay, the method <code>apply</code> would return an empty <code>Optional</code>, and no event would reach the topic. A <code>COMPLETED</code> event visible after exactly two deliveries is therefore incompatible with the database having kept anything from the first attempt. The single movement of money excludes a double application, and the presence of the event excludes a first attempt that committed.</p>
<p>This form of evidence requires no observation of any intermediate state, which is its practical value. Establishing the rollback directly would mean reading the database during the interval between the writes and the abort.</p>
<p>The abort appears in the application log as follows.</p>
<pre><code class="language-plaintext">SRMSG18262: Aborting transaction for producer id
            kafka-producer-transfer-events in channel transfer-events
</code></pre>
<h2>8. A Business Rejection Is an Outcome</h2>
<p>A transfer may be refused for reasons that belong to the business rather than to the infrastructure. The source account holds insufficient funds, an account identifier names no account, or the amount is invalid. Treating such a case as a transaction failure would be a mistake, and the reason is instructive.</p>
<p>An aborted transaction returns the message to the broker, and the broker delivers it again. A request refused for insufficient funds will be refused again on the second delivery, and on every delivery thereafter, which produces an unbounded loop.</p>
<p>The implementation therefore distinguishes the two categories. A business rejection is recorded as a committed outcome: a transfer row is written with the status <code>REJECTED</code>, the balances remain as they were, a rejection event carrying the reason is published, and the Kafka transaction commits so the offset advances. Transaction abort is reserved for infrastructure failure.</p>
<p>The distinction is visible in the code shown in section 5.3, where <code>ApplicationException</code> is caught and routed to <code>reject</code>, while any other runtime exception propagates and aborts.</p>
<p>One detail of that routing requires explicit statement, because it is a common source of defects. The rejection is written in a fresh transaction rather than in the one that failed. A JTA transaction in which a runtime exception has been raised is already marked rollback only, and further writes in it would be discarded at commit time.</p>
<h2>9. The Residual Window and the Idempotency Ledger</h2>
<p>The database commits before the Kafka transaction does, so an interval separates the two commits.</p>
<p>The case examined in this section is hypothetical. Its premise is that the process terminates during that interval which separates the two commits, for a reason outside the application, such as the container being stopped, the node failing or the operating system ending the process. No instruction in the handler produces that termination, and the implementation has no means of preventing it.</p>
<p>Suppose therefore that the process ends after Narayana has committed the database transaction and before the Kafka transaction has been decided. The database change survives, because a committed transaction is durable. The Kafka transaction is undecided, because the application that would have committed it no longer exists. The coordinator will eventually abort it, which leaves the consumed offset uncommitted.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6afb2ac0836d162959b63177/15d43f23-3d81-4ba0-bad0-633b73823837.png" alt="Sequence diagram of the residual window" style="display:block;margin:0 auto" />

<p>The abort arrives by one of two routes. The coordinator aborts a transaction that stays open beyond its timeout, and the restarted process increments the epoch of its <code>transactional.id</code> during initialization, which fences the previous instance and resolves the transaction it abandoned. Either route leaves the offset uncommitted.</p>
<p>The consequence is the redelivery, after the process restarts, of a message whose effect is already persistent. The implementation renders that redelivery harmless with the idempotency ledger introduced in section 5.2. The <code>PROCESSED_REQUESTS</code> table carries one row per request identifier, written in the same database transaction as the transfer itself, and the handler consults it before performing any work. A redelivered request whose row is already present produces no second movement of money and no second event, and the transaction commits so the offset advances.</p>
<p>The request identifier is carried by the Kafka record key, which gives each logical request a stable name across deliveries.</p>
<p>This case is not reproduced in the test suite, since killing a process at a chosen instant would make the assertions depend on timing. What the test suite does verify is the mechanism that absorbs the consequence, by publishing the same request identifier twice and asserting that the money moves only once and that one event is observed. That is the fourth row of the table in section 10, and it exercises the same path a redelivery after a restart would take.</p>
<p>Taking sections 6 through 9 together, the resulting guarantee is effectively once processing: every outcome is applied exactly one time, achieved through atomic commitment where the protocols allow it and through idempotency where the interval between two commitment points remains.</p>
<h2>10. What the Test Suite Establishes</h2>
<p>Each test in the current test suite examines the database state, what a <code>read_committed</code> consumer received, and the number of deliveries.</p>
<table>
<thead>
<tr>
<th>Case</th>
<th>Deliveries</th>
<th>Balances</th>
<th>Event observed</th>
</tr>
</thead>
<tbody><tr>
<td>A valid request</td>
<td>1</td>
<td>moved once</td>
<td>one, status <code>COMPLETED</code></td>
</tr>
<tr>
<td>A failure between the two commits</td>
<td>2</td>
<td>moved once</td>
<td>one, status <code>COMPLETED</code></td>
</tr>
<tr>
<td>Insufficient funds</td>
<td>1</td>
<td>unchanged</td>
<td>one, status <code>REJECTED</code>, carrying the reason</td>
</tr>
<tr>
<td>A request already applied</td>
<td>2</td>
<td>moved once</td>
<td>one</td>
</tr>
</tbody></table>
<p>The second and fourth rows in the table above demonstrate that two deliveries produce a single effect.</p>
<p>The module also satisfies the shared contract that the XA and saga implementations satisfy, through the same abstract test class, which establishes that the three implementations differ in transaction strategy alone.</p>
<pre><code class="language-plaintext">Tests run: 5, Failures: 0, Errors: 0 -- in MoneyTransferKafkaIT
Tests run: 4, Failures: 0, Errors: 0 -- in TransferKafkaTransactionIT
</code></pre>
<p>Across the whole repository the reactor runs 27 integration tests, and the end to end script that drives the assembled stack over HTTP reports 101 passing assertions.</p>
<h2>11. Running the Demonstration</h2>
<p>Integration tests use Quarkus Dev Services, so a running Docker daemon suffices and no manual broker or database setup is required.</p>
<pre><code class="language-bash">mvn clean verify
</code></pre>
<p>The assembled stack runs under Compose, with a single Kafka broker in KRaft mode alongside the databases, the XA and 2PC implementation and the saga and LRA implementation.</p>
<pre><code class="language-bash">mvn clean package
docker compose up -d
./test-all.sh
</code></pre>
<p>One Compose setting requires explicit configuration, because its default value prevents a transactional producer from initialising on a single broker.</p>
<pre><code class="language-yaml">KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
</code></pre>
<p>Both default to 3. The transaction log described in section 2.2 is an ordinary Kafka topic and obeys ordinary replication rules, so a single broker cluster must relax them.</p>
<p>The two paths may also be driven by hand.</p>
<pre><code class="language-bash">BODY='{"sourceAccountId":"ACC90","destinationAccountId":"ACC91",
"amount":30.00,"currency":"EUR"}'

curl -s -XPOST -H 'Content-Type: application/json' -d "$BODY" \
  'http://localhost:8095/kafka/requests?requestId=demo-1'
curl -s http://localhost:8095/kafka/events
curl -s http://localhost:8095/kafka/deliveries

curl -s -XPOST http://localhost:8095/kafka/fail-once/demo-2
curl -s -XPOST -H 'Content-Type: application/json' -d "$BODY" \
  'http://localhost:8095/kafka/requests?requestId=demo-2'
curl -s http://localhost:8095/kafka/deliveries
</code></pre>
<p>The second sequence injects one failure, so the delivery count for <code>demo-2</code> becomes two while the balance moves once.</p>
<h2>12. Comparison with the Two Earlier Implementations</h2>
<p>The repository now contains three answers to the same requirement, which permits a comparison on evidence.</p>
<table>
<thead>
<tr>
<th></th>
<th>XA and 2PC</th>
<th>Saga and LRA</th>
<th>Chained Kafka and JTA</th>
</tr>
</thead>
<tbody><tr>
<td>Coordinator</td>
<td>Narayana, embedded in the application process</td>
<td>A separate LRA coordinator that calls participants back</td>
<td>Two coordinators, Narayana for the database and a Kafka broker for the log</td>
</tr>
<tr>
<td>Resources covered atomically</td>
<td>Both databases</td>
<td>Each local step, with compensation above them</td>
<td>Produced records, consumer offsets and transaction state, with the database chained</td>
</tr>
<tr>
<td>Isolation</td>
<td>Total, since nothing is observable before commit</td>
<td>A reservation is observable while the saga is in flight</td>
<td>Records are withheld from <code>read_committed</code> consumers until commit</td>
</tr>
<tr>
<td>Recovery from an interrupted outcome</td>
<td>The Narayana recovery manager resolves in doubt branches</td>
<td>The coordinator retries the completion callbacks</td>
<td>The broker expires and aborts, and the message is redelivered</td>
</tr>
<tr>
<td>Residual exposure</td>
<td>Resources are locked between prepare and commit</td>
<td>Compensation is visible as an audit trail</td>
<td>One interval between two commits, absorbed by idempotency</td>
</tr>
<tr>
<td>Coupling</td>
<td>The two databases live under one process</td>
<td>Participants are autonomous</td>
<td>The application and the broker are independently recoverable</td>
</tr>
</tbody></table>
<p>The property distinguishing the chained Kafka and JTA arrangement from the XA and 2PC one is the nature of its recovery. XA restores the intended outcome by completing a prepared transaction. The chained arrangement restores it by replaying the input, which is available because the consumer offset was part of the transaction that aborted. Replay is a weaker instrument than prepared state, but it is sufficient whenever the work it replays is idempotent.</p>
<h2>13. The Present and the Future</h2>
<p>The arrangement described here is the strongest available today for an application that consumes a message and must change a database as a consequence.</p>
<h3>13.1 Kafka as a participant in an external two phase commit</h3>
<p><a href="https://issues.apache.org/jira/browse/KAFKA-15370">KIP-939, "Support Participation in 2PC"</a> proposes to let a Kafka producer act as a participant in an externally coordinated two phase commit. It introduces a broker configuration named <code>transaction.two.phase.commit.enable</code> and client methods <code>prepareTransaction</code> and <code>completeTransaction</code>, which together supply the half of the protocol an external transaction manager requires. The work remains in progress, the Apache issue currently targets a future release, and the <a href="https://developers.redhat.com/blog/2026/01/08/kafka-monthly-digest-december-2025">Kafka monthly digest for December 2025</a> reports that the public API changes were reverted for the time being. Should it be released, a further step would still be required, namely an adapter presenting a Kafka producer to Narayana as an XA resource.</p>
<h3>13.2 The transactional outbox, and the belief that it is the only option</h3>
<p>A widely held view holds that the transactional outbox, driven by change data capture, is the only correct way to change a database and publish to Kafka in one operation. The view deserves a carreful examination.</p>
<p>The pattern operates as follows. The application writes the business rows and a row describing the event to be published into the same database, inside one local transaction. Publication becomes a separate concern, carried out afterward by a relay that reads the outbox and writes to Kafka. In the Debezium form of that relay the reading is performed through logical decoding of the PostgreSQL write ahead log over the streaming replication protocol, which means the relay observes committed changes as the database records them rather than by polling the outbox table, and the <a href="https://debezium.io/documentation/reference/stable/transformations/outbox-event-router.html">Outbox Event Router</a> transformation turns each captured row into a message whose topic derives from the aggregate type and whose key derives from the aggregate identifier. A simpler variant replaces change data capture with a process that queries the outbox table on a schedule, and that variant is the one the word polling describes accurately.</p>
<p>The upsides of this pattern are:</p>
<ul>
<li>atomicity becomes local, since one database transaction covers both the business change and the intent to publish, so no distributed protocol participates in the critical path;</li>
<li>availability improves, since the event is durable once that transaction commits, and a broker that is unreachable delays publication while leaving the business operation unaffected.</li>
</ul>
<p>But they aren't for free as the following costs accompany them:</p>
<ul>
<li>the deployment requires an additional component, namely Kafka Connect with a specialized connector;</li>
<li>the database requires an output plugin for logical decoding and a replication slot;</li>
<li>publication becomes asynchronous, so the event appears some time after the commit rather than within the operation that caused it;</li>
<li>the outbox table requires pruning.</li>
</ul>
<p>The downside of the pattern concerns direction, and it is the subject of section 4. An outbox addresses the outbound direction, in which a database change must produce an event. The arrangement described in this article addresses the inbound direction, in which a message must produce a database change. Applied to the inbound direction, an outbox covers one half of the problem, because the resource that must return to its previous value is the consumer offset, and no table in the database holds it. An application may close that half by recording the consumed offset in the database as well and by seeking to the recorded position whenever the consumer starts, which makes the database the single authority over both the effect and the progress. That arrangement is correct, and it is the natural companion of an outbox, at the cost of managing partition assignment and seeking explicitly, which is the work that <code>withTransactionAndAck</code> performs here through a single argument.</p>
<h2>14. Conclusion</h2>
<p>Until KIP-939 or an equivalent proposal changes the landscape, the conclusion is a practical one. A Kafka transaction covers produced records and consumer offsets under a broker side coordinator that records every decision in a replicated log. Chaining a database transaction inside it extends atomic behavior to every failure the application itself raises, makes the input replayable whenever the outcome is in doubt, and leaves a single interval that an idempotency ledger closes. For the overwhelming majority of services that consume a message and change a database, that is the guarantee they actually need.</p>
<h2>References and Further Reading</h2>
<ul>
<li><a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-98+-+Exactly+Once+Delivery+and+Transactional+Messaging">KIP-98, Exactly Once Delivery and Transactional Messaging</a>, the specification of Kafka transactions.</li>
<li><a href="https://issues.apache.org/jira/browse/KAFKA-15370">KAFKA-15370, Support Participation in 2PC</a>, tracking KIP-939.</li>
<li><a href="https://smallrye.io/smallrye-reactive-messaging/latest/kafka/transactions/">Kafka Transactions and Exactly-Once Processing</a>, the SmallRye Reactive Messaging reference for the <code>KafkaTransactions</code> emitter.</li>
<li><a href="https://quarkus.io/guides/kafka">Apache Kafka Reference Guide</a>, the Quarkus guide, whose sections on exactly once processing and on chaining Kafka transactions with Hibernate ORM transactions describe the forms used here.</li>
<li><a href="https://quarkus.io/guides/kafka-dev-services/">Dev Services for Kafka</a>, including the broker providers available for testing.</li>
<li><a href="https://quarkus.io/guides/transaction">Using transactions in Quarkus</a>, for the Narayana side of the arrangement.</li>
<li><a href="https://www.simplex-software.fr/posts-archive/quarkus-2pc-lra/">Distributed Transactions in Enterprise Applications: From X/Open to MicroProfile LRA</a>, the first article in this series, covering the XA and saga implementations compared in section 12.</li>
<li><a href="https://debezium.io/documentation/reference/stable/transformations/outbox-event-router.html">Debezium Outbox Event Router</a>, the transformation that turns captured outbox rows into messages.</li>
<li><a href="https://debezium.io/documentation/reference/stable/connectors/postgresql.html">Debezium connector for PostgreSQL</a>, describing the logical decoding of the write ahead log on which the relay of section 13.2 depends.</li>
<li><a href="https://github.com/nicolasduminil/quarkus-distributed-tx"><code>quarkus-distributed-tx</code></a>, the repository containing all three implementations and the shared test suite.</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Reactive vs Virtual Threads in Quarkus]]></title><description><![CDATA[This article compares the reactive style, as provided by Mutiny, with virtual threads, on one on demand HTTP operation. It explains how the two relate…]]></description><link>https://nicolasduminil.hashnode.dev/reactive-vs-virtual-threads-in-quarkus</link><guid isPermaLink="true">https://nicolasduminil.hashnode.dev/reactive-vs-virtual-threads-in-quarkus</guid><dc:creator><![CDATA[nicolasduminil]]></dc:creator><pubDate>Mon, 16 Nov 2026 16:27:50 GMT</pubDate><content:encoded><![CDATA[<h2>Abstract</h2>
<p>This article compares the reactive style, as provided by Mutiny, with virtual threads, on one on demand HTTP operation. It explains how the two relate, shows the sequence diagram and code of each example, and analyzes the tests together with a load measurement. The most instructive results of this article contradict the expectations that I might have had before. The reader will therefore find here a full report on what was measured.</p>
<h2>1. Introduction</h2>
<p>The arrival of virtual threads in Java 21 has produced a debate more abundant in convictions than in figures. One party regards reactive pipelines as the only respectable way of waiting for a network, and another announces that they have lost their reason to exist. This article prefers a measurement, and it makes one modest request of the reader, namely to be critical against these measurement as well.</p>
<p>The operation under study is the retrieval of a stock quote from the <a href="https://finnhub.io">Finnhub</a> REST API. It originates from a project concerning <a href="https://github.com/nicolasduminil/reactive-messaging">Reactive Messaging</a>, whose <a href="https://github.com/nicolasduminil/reactive-messaging">companion article</a> applies virtual threads to the consumers of a Kafka topic. The present service is independent of it, and it uses no channel and no broker.</p>
<p>The software versions used throughout are Java 21.0.3, Quarkus 3.40.1.1 and Mutiny 3.3.0. The full source code of the project can be found <a href="https://github.com/nicolasduminil/mutiny-virtual-threads">here</a>.</p>
<h2>2. The reactive style and the virtual thread style</h2>
<p>Both styles answer the same question, which is how a server can serve many concurrent requests that spend most of their time waiting for the network, while a platform thread remains an expensive resource.</p>
<p>The reactive answer avoids waiting altogether. Quarkus builds its network layer on Eclipse Vert.x, a toolkit for event driven applications on the JVM. Vert.x supplies the HTTP server that receives every request and the HTTP client that carries every call of the REST client. A small number of Vert.x event loop threads, which are ordinary platform threads, execute short callbacks, and the code is expressed as a pipeline of transformations. The answer of virtual threads, finalized in Java 21 by JEP 444, renders the waiting inexpensive. The code blocks in the most traditional manner, but what blocks is a lightweight thread that the JVM parks, not the carrier one, which is released for other work.</p>
<p>The two styles are alternatives, and they do not form a progression in which the second supersedes the first. The project presents both, side by side, in a single service.</p>
<p>The resource exposing the blocking method requires a single annotation, <code>@RunOnVirtualThread</code>.</p>
<table>
<thead>
<tr>
<th>Criterion</th>
<th>Mutiny</th>
<th><code>@RunOnVirtualThread</code></th>
</tr>
</thead>
<tbody><tr>
<td>Thread serving the request</td>
<td>an event loop, which must remain unblocked</td>
<td>one virtual thread per request</td>
</tr>
<tr>
<td>Code style</td>
<td>a composed pipeline, each step being a callback</td>
<td>sequential statements and ordinary control flow</td>
</tr>
<tr>
<td>Error handling</td>
<td>failure operators in the pipeline</td>
<td><code>try</code> and <code>catch</code></td>
</tr>
<tr>
<td>Back pressure</td>
<td>a part of the model, as in the signal stream of the companion article</td>
<td>absent by default, to be provided explicitly</td>
</tr>
<tr>
<td>Streams</td>
<td>natural, through <code>Multi</code></td>
<td>requires additional constructions</td>
</tr>
<tr>
<td>Principal hazard</td>
<td>a blocking call stalls every request on that event loop</td>
<td>a <code>synchronized</code> block around I/O pins the carrier on JDK 21</td>
</tr>
</tbody></table>
<p>Two remarks qualify this table. First, the listing above contains one step only, and at this scale neither style exhibits a worthy readability advantage. But as soon as branching, loops and error handling appear in the code, the difference becomes perceptible. Second, the pinning hazard depends on the Java version. JEP 491, delivered in JDK 24, allows virtual threads to hold monitors independently of their carriers, which removes pinning caused by <code>synchronized</code>. The pinning through native code remains however possible. As this project runs on Java 21, the hazard applies in full and section 4 tests it accordingly.</p>
<h2>3. The service, one operation in five forms</h2>
<p>Virtual threads appear in this project beside Mutiny, so a precise distinction is required before going further. Section 2 presented the two styles as alternative solutions to the same problem. While this is true from the point of view of the manner in which a request spends its waiting time, as mechanisms, however, they belong to different categories. Mutiny is a library for composing asynchronous operations. A <code>Uni</code> is a lazy description of what must happen, it executes nothing before a subscriber appears, and its steps run on whichever thread subscribes to it or delivers its item. A virtual thread, by contrast, is a unit of execution provided by the JVM, and it knows nothing of the operations it carries. The first concerns the composition of the work, and the second concerns what executes it. This explains why the two can be combined at all.</p>
<p>The use case is deliberately elementary. A client performs an HTTP request to obtain the current quote of a given stock and remains connected until the response arrives. The following request illustrates this exchange.</p>
<pre><code class="language-shell">curl http://localhost:8080/api/v1/quote/reactive/AAPL
</code></pre>
<p>The service answers with the corresponding <code>Quote</code>, serialized as JSON.</p>
<pre><code class="language-json">{"previousClose":259.71,"price":261.74,"symbol":"AAPL"}
</code></pre>
<p>Serving such a request requires three successive operations:</p>
<ol>
<li>the validation of the symbol against the pattern <code>[A-Z0-9.:-]{1,20}</code></li>
<li>a call to the <code>/quote</code> operation of Finnhub, which carries the symbol and the API token</li>
<li>the conversion of the answer into a <code>Quote</code>, a price of zero denoting an unknown symbol</li>
</ol>
<p>The first and the third operations consume a negligible amount of processor time, and the second one consumes nearly the entire duration of the request, which is spent waiting for the remote service. A large number of concurrent requests waiting for the network is precisely the situation that both the reactive style and virtual threads were designed to address. With so little business logic, any difference between the implementations can only originate in the manner of waiting for the result.</p>
<p>The service exposes this single operation through five endpoints, which differ only in one segment of their path and return the same JSON payload.</p>
<table>
<thead>
<tr>
<th>Path segment</th>
<th>Finnhub client</th>
<th>Thread serving the request</th>
<th>Thread waiting for Finnhub</th>
</tr>
</thead>
<tbody><tr>
<td><code>reactive</code></td>
<td>reactive</td>
<td>Vert.x event loop thread</td>
<td>none</td>
</tr>
<tr>
<td><code>virtual</code></td>
<td>blocking</td>
<td>virtual thread</td>
<td>the same virtual thread</td>
</tr>
<tr>
<td><code>offload-worker</code></td>
<td>blocking</td>
<td>Vert.x event loop thread</td>
<td>worker pool thread</td>
</tr>
<tr>
<td><code>offload-virtual</code></td>
<td>blocking</td>
<td>Vert.x event loop thread</td>
<td>virtual thread</td>
</tr>
<tr>
<td><code>await</code></td>
<td>reactive</td>
<td>virtual thread</td>
<td>the same virtual thread</td>
</tr>
</tbody></table>
<p>The first two endpoints implement the alternatives shown in the sequence diagram below, and the remaining three combine them, as explained further on.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6afb2ac0836d162959b63177/64b0e9e6-a681-4af0-9617-802742a08f08.png" alt="" style="display:block;margin:0 auto" />

<img src="diagrams/01-quote-two-models.png" alt="Sequence diagram of the two models" style="display:block;margin:0 auto" />

<p>The two endpoints, <code>/api/v1/quote/reactive</code> and respectively <code>/api/v1/quote/virtual</code> are served by the following REST services.</p>
<pre><code class="language-java">@Path("/api/v1/quote/reactive")
public class ReactiveQuoteResource
{
  ...
  @GET
  @Path("/{symbol}")
  public Uni&lt;Quote&gt; quote(
    @PathParam("symbol") @Pattern(regexp = QuoteSymbol.PATTERN) String symbol)
  {
    return service.fetchReactive(symbol);
  }
}

...

@Path("/api/v1/quote/virtual")
public class VirtualThreadQuoteResource
{
  ...
  @GET
  @Path("/{symbol}")
  @RunOnVirtualThread
  public Quote quote(
    @PathParam("symbol") @Pattern(regexp = QuoteSymbol.PATTERN) String symbol)
  {
    return service.fetchBlocking(symbol);
  }
}
</code></pre>
<p>A method returning a <code>Uni</code> is considered non-blocking, and it runs on a Vert.x event loop thread. A method returning a plain object is considered blocking, and it would normally run on a thread of the worker pool, which is a platform thread as well, unless the <code>@RunOnVirtualThread</code> annotation directs it to a virtual thread created for this request. The return type plays the same role as far as the REST clients are concerned. <code>FinnhubClient</code> declares:</p>
<pre><code class="language-java">@RegisterRestClient(configKey = "finnhub")
public interface FinnhubClient
{
  @GET
  @Path("/quote")
  Uni&lt;FinnhubQuote&gt; quote(@QueryParam("symbol") String symbol,
      @QueryParam("token") String token);
}
</code></pre>
<p>while its counterpart, <code>FinnhubBlockingClient</code>, has different signatures:</p>
<pre><code class="language-java">@RegisterRestClient(configKey = "finnhub")
public interface FinnhubBlockingClient
{
  @GET
  @Path("/quote")
  FinnhubQuote quote(@QueryParam("symbol") String symbol,
      @QueryParam("token") String token);
}
</code></pre>
<p>The two interfaces thus describe one remote operation, and they differ only in the behavior they impose upon the calling thread.</p>
<p>The upper part of the diagram shows the reactive path. A Vert.x event loop thread invokes the resource method, which merely constructs the pipeline and returns it. An event loop thread is an ordinary platform thread, belonging to a pool whose default size equals the number of processors. Quarkus then subscribes to this pipeline, the client sends its request without blocking, and the event loop thread proceeds to other requests. During the interval that separates the request from its answer, no thread is waiting for Finnhub. When the answer arrives, a callback executes the <code>map</code> step on the same event loop thread and the response is written. A small number of event loop threads can consequently serve a large number of requests, on the strict condition that each step remains brief. A blocking call on this thread would stall every request sharing the event loop, and Quarkus therefore refuses it by raising a <code>BlockingNotAllowedException</code>.</p>
<p>The lower part of the diagram shows the virtual thread path. Quarkus dispatches the request to a new virtual thread, whose code executes sequentially and calls the blocking client in the most traditional manner. While this call waits for the answer, the JVM parks the virtual thread, which means that it preserves its stack on the heap and unmounts it from its carrier. A carrier is an ordinary platform thread, belonging to a scheduler whose default size equals the number of processors, and once released it may execute another virtual thread. When the answer arrives, the virtual thread is scheduled again, possibly on a different carrier, and it resumes at the following statement, with its local variables and its enclosing <code>try</code> blocks intact. It remains unaware of having been absent, a privilege rarely granted to those who sleep during working hours.</p>
<p>Such a thread is inexpensive because its stack grows on the heap according to need, whereas a platform thread reserves its stack in advance, by default one megabyte on common 64 bit platforms. Each request can therefore receive its own virtual thread, and pooling them would defeat their purpose. Two conditions qualify this apparent gratuity. The first is that the thread must be able to unmount, and on Java 21 a virtual thread blocking inside a <code>synchronized</code> block remains pinned to its carrier. The tests accordingly apply the annotation <code>@ShouldNotPin</code> to the virtual thread endpoints. The second is that inexpensive waiting removes a limit which was also serving as a protection, a subject to which section 5.1 returns.</p>
<p>The measurements of section 4 show both paths reaching the same theoretical ceiling, so the choice between them rests on the style of the code and on the hazards listed in section 2, rather than on throughput.</p>
<p>The service then addresses the narrower question of combining these two styles. The realistic scenario is a reactive pipeline that calls an endpoint that offers only a blocking client. Quarkus rejects such a call on the event loop platform thread with an exception, so the call must move elsewhere, and the choice of its destination is what the two offloading endpoints compare.</p>
<p>The class <code>QuoteService</code> exposes two methods, <code>offloadToWorkerPool(...)</code> and <code>offloadToVirtualThread(...)</code>, which move the blocking call away from the event loop platform thread. The first moves it to another thread of the worker pool, which is a platform thread as well. This transfer between two platform threads keeps the cost of the wait unchanged, because the waiting thread remains a platform thread. What it changes is the obligation attached to the thread. An event loop thread serves the requests of many connections and must remain free at every instant, whereas a worker pool thread serves one call at a time and may block while delaying that call alone. The worker pool thread nevertheless remains occupied during the entire wait, so the size of the pool bounds the number of concurrent calls. The second method moves the call to a virtual thread, which obtains the same permission to block, while the wait occupies a parked virtual thread instead of a platform thread.</p>
<p>The class <code>QuoteService</code> also exposes the method <code>awaitOnVirtualThread(...)</code> which does the reverse of <code>offload(...)</code> and calls the non-blocking reactive client from sequential code, and waits for the result by blocking the current virtual thread.</p>
<pre><code class="language-java">@ApplicationScoped
public class QuoteService
{
   private final FinnhubClient reactiveClient;
   private final FinnhubBlockingClient blockingClient;
   private final FinnhubConfig config;
   private final ExecutorService virtualThreads;

   public QuoteService(@RestClient FinnhubClient reactiveClient,
                       @RestClient FinnhubBlockingClient blockingClient,
                       FinnhubConfig config,
                       @VirtualThreads ExecutorService virtualThreads)
   {
      this.reactiveClient = reactiveClient;
      this.blockingClient = blockingClient;
      this.config = config;
      this.virtualThreads = virtualThreads;
   }

   public Uni&lt;Quote&gt; fetchReactive(String symbol)
   {
      return reactiveClient.quote(symbol, token())
          .map(quote -&gt; toQuote(symbol, quote));
   }

   public Quote fetchBlocking(String symbol)
   {
      return toQuote(symbol, blockingClient.quote(symbol, token()));
   }

   public Uni&lt;Quote&gt; offloadToWorkerPool(String symbol)
   {
      return offload(symbol, Infrastructure.getDefaultWorkerPool());
   }

   public Uni&lt;Quote&gt; offloadToVirtualThread(String symbol)
   {
      return offload(symbol, virtualThreads);
   }

   public Quote awaitOnVirtualThread(String symbol)
   {
      return fetchReactive(symbol).await().indefinitely();
   }

   private Uni&lt;Quote&gt; offload(String symbol, Executor executor)
   {
      return Uni.createFrom().item(() -&gt; fetchBlocking(symbol))
          .runSubscriptionOn(executor);
   }

   private String token()
   {
      return config.token().orElse("");
   }

   private static Quote toQuote(String symbol, FinnhubQuote quote)
   {
      if (quote.current().signum() == 0)
         throw new QuoteNotFoundException(symbol);
      return new Quote(symbol, quote.current(), quote.previousClose());
   }
}
</code></pre>
<p>The method <code>offload</code> deserves a careful reading, because it expresses the essence of the combination. The call <code>Uni.createFrom().item(...)</code> wraps the blocking operation in a lazy <code>Uni</code>, whose supplier executes at the moment of subscription. The operator <code>runSubscriptionOn</code> determines the thread on which this subscription occurs, and consequently the thread on which the blocking call runs. The resource method returns its <code>Uni</code> immediately, so the event loop remains free, and the signature declares a non-blocking operation. The operator <code>emitOn</code> would be an unfortunate substitute, since it only displaces the steps located downstream and it would leave the blocking call on the event loop.</p>
<p>The two offloading endpoints differ in one argument only, namely the executor. The first receives the default worker pool, whose threads are limited in number and each of which remains occupied during the entire call. The second receives an <code>ExecutorService</code> injected with the qualifier <code>@VirtualThreads</code>, which starts a virtual thread for each task. This annotated executor is preferred to <code>Executors.newVirtualThreadPerTaskExecutor()</code> because Quarkus propagates the context through it and governs its lifecycle. In both cases the method returns a <code>Uni</code>, so the caller may continue to compose it with the operators of Mutiny, for instance in order to retry the call or to recover from a failure. The two differ solely in the resource consumed during the wait, namely a platform thread that remains occupied in the first case, and a virtual thread that is parked while its carrier is released in the second.</p>
<p>The <code>await</code> endpoint performs the inverse operation. Its resource method carries <code>@RunOnVirtualThread</code>, and it calls the reactive client through <code>await().indefinitely()</code>, which subscribes to the <code>Uni</code> and blocks the caller until an item or a failure arrives. The HTTP exchange remains non-blocking, and the only thread that waits is the virtual thread, as the lower part of the following diagram shows. This call is possible only on a thread permitted to block. On an event loop, Mutiny raises an <code>IllegalStateException</code> with the message "The current thread cannot be blocked". The adverb <code>indefinitely</code> should alarm no reader, since the read timeout of 5 seconds concludes the wait with status 504, and the tests verify it. This form is useful when sequential code must exploit a library offering only a reactive interface.</p>
<p>One might wish to shorten the journey by annotating a method that returns a <code>Uni</code> with <code>@RunOnVirtualThread</code>. Quarkus 3.40 logs an error stating that the method was "both @NonBlocking and @RunOnVirtualThread", then starts normally and runs the method on a virtual thread, a form of protest followed by immediate compliance. The project avoids this combination, and it keeps these models in separate resources.</p>
<p>The presented combination of the two styles is by no means a general improvement. It serves a reactive pipeline obliged to call a blocking producer under a load capable of exhausting the worker pool. It also serves a sequential code obliged to call a reactive client. A pipeline containing no blocking call gains nothing from it, and section 4 shows that the two offloading strategies are indistinguishable at 100 connections.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6afb2ac0836d162959b63177/f661002b-efb1-4602-8b42-a702a0b854c1.png" alt="" style="display:block;margin:0 auto" />

<img src="diagrams/02-quote-combined.png" alt="Sequence diagram of the combined patterns" style="display:block;margin:0 auto" />

<p>All endpoints honor one error contract, expressed as RFC 9457 Problem Details:</p>
<table>
<thead>
<tr>
<th>Situation</th>
<th>Status</th>
</tr>
</thead>
<tbody><tr>
<td>Invalid symbol</td>
<td>400, with <code>errors</code> naming the parameter</td>
</tr>
<tr>
<td>Zero price from Finnhub, treated as an unknown symbol</td>
<td>404</td>
</tr>
<tr>
<td>Finnhub answers with an error, or the connection fails</td>
<td>502</td>
</tr>
<tr>
<td>Finnhub exceeds the read timeout of 5 seconds</td>
<td>504</td>
</tr>
<tr>
<td>Unexpected failure</td>
<td>500</td>
</tr>
</tbody></table>
<p>The details are fixed strings, as the URL of the upstream call carries the API token, and the text of an exception raised by a client library lies beyond the control of the application.</p>
<h2>4. Running the application and the tests</h2>
<p>The project requires JDK 21 and Maven 3.9 or later. The tests require nothing more, since they replace Finnhub with a WireMock server started within the test process. A call to the real service requires a free API key, obtained from the <a href="https://finnhub.io">Finnhub</a> site, and the load comparison requires the HTTP benchmarking tool <code>wrk</code>.</p>
<p>The following commands clone the repository and execute the complete build, which compiles the code and runs the 59 tests analyzed in the next section.</p>
<pre><code class="language-shell">git clone https://github.com/nicolasduminil/mutiny-virtual-threads.git
cd mutiny-virtual-threads
mvn verify
</code></pre>
<p>A single test class runs with the option <code>-Dtest</code>, for instance <code>mvn test -Dtest=QuoteResourceTest</code>. The application reads the API key from the environment variable <code>FINNHUB_TOKEN</code>, through the property <code>finnhub.token</code>. Once packaged, it starts on port 8080 and answers on the five endpoints, which share the prefix <code>/api/v1/quote/</code> and differ in the path segment listed in Section 3.</p>
<pre><code class="language-shell">mvn package -DskipTests
FINNHUB_TOKEN=&lt;your-key&gt; java -jar target/quarkus-app/quarkus-run.jar &amp;
curl http://localhost:8080/api/v1/quote/reactive/AAPL
curl http://localhost:8080/api/v1/quote/virtual/AAPL
</code></pre>
<p>Each endpoint returns the same JSON document, for instance <code>{"previousClose":259.71,"price":261.74,"symbol":"AAPL"}</code>. In the absence of a valid key, Finnhub rejects the call and every endpoint answers with the status 502 defined by the error contract.</p>
<p>The load comparison executes the packaged application against a local stub, so it consumes no request of the Finnhub quota. The script <code>load/compare.sh</code> starts the stub and the application, measures each endpoint with <code>wrk</code>, and prints a summary grouped by number of connections. Its environment variables adjust the run, namely <code>DELAY_MS</code> for the latency of the stub, 200 ms by default, <code>DURATION</code> for the length of each measurement, 20 seconds by default, <code>CONNECTIONS</code> for the list of connection counts, and <code>MODELS</code> for the list of endpoints.</p>
<pre><code class="language-shell">mvn package -DskipTests
load/compare.sh
DELAY_MS=50 DURATION=30s load/compare.sh
</code></pre>
<h2>5. Analysis of the test results</h2>
<p>The complete build executes 59 tests, all of which pass, with no test skipped. The durations below come from a single run and include the startup of the application and of the instrumentation for pinning detection.</p>
<table>
<thead>
<tr>
<th>Test class</th>
<th>Infrastructure</th>
<th>Tests</th>
<th>Duration</th>
</tr>
</thead>
<tbody><tr>
<td><code>FinnhubQuoteTest</code></td>
<td>none</td>
<td>2</td>
<td>0.1 s</td>
</tr>
<tr>
<td><code>QuoteResourceTest</code></td>
<td>WireMock</td>
<td>57</td>
<td>16.8 s</td>
</tr>
</tbody></table>
<p>The class <code>QuoteResourceTest</code> accounts for most of the total because it executes each behavior on each of the five endpoints, comprising 50 parameterized contract cases and 7 individual cases.</p>
<p>During this work, each significant test was therefore challenged in the following manner. A bug was deliberately introduced temporarily into the code that the test protects, the test was executed in order to verify that it failed, and the code was subsequently restored. This was performed by hand, which offers considerably less rigor than a mutation testing tool, yet it yielded very valuable results:</p>
<table>
<thead>
<tr>
<th>Deliberate damage</th>
<th>Result</th>
</tr>
</thead>
<tbody><tr>
<td>Add <code>synchronized</code> around the blocking call</td>
<td><code>@ShouldNotPin</code> fails on <code>virtual</code> and <code>offload-virtual</code></td>
</tr>
<tr>
<td>Add <code>synchronized</code> around <code>await</code></td>
<td><code>@ShouldNotPin</code> fails on <code>await</code></td>
</tr>
<tr>
<td>Use the worker pool in <code>offload-virtual</code></td>
<td>the assertion on the calling thread fails</td>
</tr>
<tr>
<td>Remove <code>runSubscriptionOn</code></td>
<td>21 cases fail, as the framework rejects the blocking call</td>
</tr>
<tr>
<td>Remove <code>@RunOnVirtualThread</code> from <code>await</code></td>
<td>the assertion on the serving thread fails</td>
</tr>
<tr>
<td>Add <code>@Blocking</code> to the reactive endpoint</td>
<td>the assertion on the serving thread fails</td>
</tr>
</tbody></table>
<p>The rate limit of the Finnhub free tier excludes load tests against the real service, so the script <code>compare.sh</code> measures the endpoints with <code>wrk</code> against a local stub answering after 200 ms. Each configuration ran for 20 seconds on one 8 core machine that also hosted the load generator and the stub. The figures below thus describe that machine and should not be read as capacity predictions. Each cell gives the requests per second followed by the 99th percentile of latency, and no run reported an error.</p>
<table>
<thead>
<tr>
<th>Connections</th>
<th>Ceiling</th>
<th><code>reactive</code></th>
<th><code>virtual</code></th>
<th><code>offload-worker</code></th>
<th><code>offload-virtual</code></th>
<th><code>await</code></th>
</tr>
</thead>
<tbody><tr>
<td>100</td>
<td>500</td>
<td>494, 210 ms</td>
<td>494, 209 ms</td>
<td>494, 218 ms</td>
<td>494, 204 ms</td>
<td>494, 205 ms</td>
</tr>
<tr>
<td>500</td>
<td>2,500</td>
<td>2,472, 213 ms</td>
<td>2,471, 213 ms</td>
<td>984, 520 ms</td>
<td>2,472, 212 ms</td>
<td>2,472, 209 ms</td>
</tr>
<tr>
<td>1,000</td>
<td>5,000</td>
<td>4,939, 217 ms</td>
<td>4,920, 227 ms</td>
<td>972, 1.27 s</td>
<td>4,941, 212 ms</td>
<td>4,939, 212 ms</td>
</tr>
<tr>
<td>2,000</td>
<td>10,000</td>
<td>9,601, 281 ms</td>
<td>9,792, 241 ms</td>
<td>948, 2.79 s</td>
<td>9,814, 229 ms</td>
<td>9,749, 260 ms</td>
</tr>
</tbody></table>
<p>Three observations follow:</p>
<ol>
<li>The <code>reactive</code> and <code>virtual</code> endpoints both reach the theoretical ceiling at every tested load. This experiment therefore detects no difference of throughput between the two models, up to 10,000 requests per second, at which point a sample of processor activity, taken during an earlier campaign, showed less than 2 percent of idle time.</li>
<li>The <code>offload-worker</code> endpoint caps near 1,000 requests per second, as predicted before the measurement. The default worker pool holds the greater of 200 threads and 8 per processor, hence 200 here, and 200 threads each occupied for 200 ms deliver 1,000 requests per second. Beyond this limit, requests wait for a thread, and the latency grows accordingly.</li>
<li>The <code>offload-virtual</code> endpoint has no such pool and reaches the ceiling. At 100 connections, however, the two offloading strategies are indistinguishable.</li>
</ol>
<p>Here are some limits of tha analysis above:</p>
<ol>
<li>The tests replace Finnhub by WireMock, and the measurements by a stub.</li>
<li>The load figures concern one latency, one machine and one kind of operation, with a very small amount of work per request. An application performing substantial computation would probably behave otherwise.</li>
</ol>
<p>The result of section 4 might suggest that a pool limit is simply a defect. It is also a protection, since a limit of 200 threads bounds the concurrent calls to the dependency. Virtual threads remove the worker pool limit of 200 threads. This might be seen as an improvement but it's also a protection. Without it, a rate limited service such as Finnhub would then receive the entire load, a form of generosity that it would acknowledge with status 429. A semaphore or a dedicated limiter becomes the responsibility of the developer. It is significant that Quarkus applies a default concurrency limit of 1024 when <code>@RunOnVirtualThread</code> is used on messaging methods.</p>
<h2>6. Conclusions</h2>
<p>Regarding the choice between the two styles, the evidence collected here supports the following recommendations:</p>
<ol>
<li>Prefer virtual threads for request and response operations whose logic reads more clearly in sequence, especially when the team or the libraries are oriented toward blocking code. Check the pinning hazard if running on a version earlier than JDK 24.</li>
<li>Prefer reactive style, with Mutiny, when the application already composes asynchronous steps or requires continuous streams with explicit back pressure.</li>
<li>Do not select either model for throughput on the basis of this experiment, which detected no difference for input and output bound work up to its highest load. Readability, the existing code and the libraries available constitute better criteria.</li>
<li>Combine the models in the narrow case of a blocking dependency within an existing reactive pipeline, under concurrency sufficient to exhaust the worker pool. Below that level, the combination provides no measurable benefit, and a pipeline without any blocking call requires no combination at all.</li>
<li>Whichever style is chosen, assert the thread in the tests, identify the true limiting resource before attributing a result to a model, and vary the order of benchmark runs.</li>
</ol>
<h2>References</h2>
<ol>
<li>SmallRye, <a href="https://smallrye.io/smallrye-mutiny/">Mutiny documentation</a>.</li>
<li>Quarkus, <a href="https://quarkus.io/guides/messaging-virtual-threads">Virtual Threads Support for Messaging Applications</a>.</li>
<li>OpenJDK, <a href="https://openjdk.org/jeps/444">JEP 444, Virtual Threads</a>.</li>
<li>OpenJDK, <a href="https://openjdk.org/jeps/491">JEP 491, Synchronize Virtual Threads without Pinning</a>.</li>
<li>IETF, <a href="https://www.rfc-editor.org/rfc/rfc9457">RFC 9457, Problem Details for HTTP APIs</a>.</li>
<li>The accompanying source code, <a href="https://github.com/nicolasduminil/mutiny-virtual-threads"><code>mutiny-virtual-threads</code></a>.</li>
<li>The companion project, <a href="https://github.com/nicolasduminil/reactive-messaging"><code>reactive-messaging</code></a>.</li>
</ol>
]]></content:encoded></item></channel></rss>