symfony-nats-messenger 5.16: stream metadata behind a leaf node
(php, symfony, nats, release-notes) 19 min read by Bartosz Pachołek
5.16.0 fixes stream_metadata behind a NATS leaf node: setup() now asks the hub's JetStream for its API level before it refuses, and checks the stream it gets back. Run on hubs from NATS 2.9 to 2.15, with 5.15.0 and 5.16.0 side by side.
symfony-nats-messenger 5.16.0 is out with one fix, for a case our own 5.14 post showed going wrong: stream_metadata behind a NATS leaf node. With jetstream_domain, the stream lives on the hub, but setup() judged the option by the release of the leaf node it was connected to. A 2.9 leaf node in front of a modern hub was refused, and a modern leaf node in front of a 2.9 hub let the hub drop the labels while the setup reported success. 5.16.0 asks the hub's JetStream where it can, and checks the stream it gets back where it cannot.
We ran every example on PHP 8.5.9 against the official NATS images 2.9.25, 2.10.29, 2.11.17 and 2.15.3 in Docker, with Symfony Messenger 8.2.0 and php-nats-jetstream-client 2.42.1. We installed 5.15.0 and 5.16.0 from Packagist side by side with the same composer.lock, so only the transport differs. The outputs are pasted as they came out.

What went wrong on a leaf node
stream_metadata, added in 5.14.0, writes labels on the stream the transport sets up. { team: billing } lands in the stream's metadata map, where nats stream info and other tools can read it. NATS added that map in 2.10. A 2.9 server accepts a stream configuration that carries it and drops the field without a word, so the transport refuses the option on a server before 2.10 rather than create a stream without its labels.
The question is which server. Up to 5.15.0, setup() read the version the server gave in its INFO when the connection opened. Without a leaf node, that is the server that holds the stream. A leaf node is different: it brings a hub's subjects to a site, a store or an edge service, and when it has no JetStream of its own, the transport reaches the hub's JetStream through jetstream_domain, with every API request sent as $JS.hub.API. instead of $JS.API.. The stream lives on the hub, and the check read the leaf node. Two wrong answers followed:
- A leaf node before 2.10 in front of a hub of 2.10 or later was refused, though the hub would keep the labels.
- A leaf node of 2.10 or later in front of a hub before 2.10 was let through. The hub dropped the labels, and the setup succeeded.
Our symfony-nats-messenger 5.14 post ran both directions and advised running 2.10 or later on both sides, then looking at the labels on the hub after the first setup. Issue #204 wrote the same two cases down on 2 December, found while #139 (the stream_metadata pull request) was brought up to date with main, together with a way to fix the first before the write and the second after it:

The fix: ask the JetStream that holds the stream
NATS 2.11 introduced the JetStream API level (ADR-44). The account info a JetStream returns on $JS.API.INFO carries api.level, a number that grows with the features that JetStream supports. 5.13.0 already reads it for scheduled_messages (our symfony-nats-messenger 5.13 post covers that story), through the transport's own context, so under the domain. 5.16.0 uses the same read for metadata, in two places:
- Before it refuses. When the connected server reports a release before 2.10,
setup()asks for the API level first. A level of 1 or more means a JetStream of 2.11 or later, which keeps the labels, and the setup goes on. The level is read once per connection and shared withscheduled_messages. A connected server of 2.10 or later gets no new request. - After the write. Once the create or the update returns,
setup()compares the stream it got back with the entries the option sets. A missing entry means the JetStream that holds the stream dropped it, and the setup fails.
The level cannot tell 2.9 from 2.10, because neither reports one. So a 2.9 leaf node in front of a 2.10 hub stays refused: the transport cannot prove the hub would keep the labels.
Proof of concept: four hubs and their leaf nodes
Every example below runs on one Compose project. There is a hub with JetStream under the domain hub for each of four releases, a leaf node with no JetStream in front of each, a fifth leaf node with a restricted user, and a 2.9.25 server on its own:
# Four hubs with JetStream under the domain "hub", one per release, a leaf node with no
# JetStream in front of each, and one server alone. Host ports:
# hub29 14861 nats-server 2.9.25, before stream metadata
# leaf215 14862 nats-server 2.15.3, leaf node of hub29
# hub210 14863 nats-server 2.10.29, the first release with stream metadata
# leaf29x210 14864 nats-server 2.9.25, leaf node of hub210
# hub211 14865 nats-server 2.11.17, the first release with a JetStream API level
# leaf29x211 14866 nats-server 2.9.25, leaf node of hub211
# hub215 14867 nats-server 2.15.3
# leaf29x215 14868 nats-server 2.9.25, leaf node of hub215
# guarded29 14869 nats-server 2.9.25, leaf node of hub215, user "app" may not ask
# for the API level
# solo29 14870 nats-server 2.9.25 with JetStream of its own, no leaf node
x-leaf: &leaf
volumes: ["./leaf.conf:/etc/nats/leaf.conf:ro"]
services:
hub29:
image: nats:2.9.25-alpine
command: ["-c", "/etc/nats/hub.conf", "--server_name", "hub29"]
volumes: ["./hub.conf:/etc/nats/hub.conf:ro"]
ports: ["14861:4222"]
leaf215:
<<: *leaf
image: nats:2.15.3-alpine
command: ["-c", "/etc/nats/leaf.conf", "--server_name", "leaf215"]
environment: { HUB: "nats-leaf://hub29:7422" }
ports: ["14862:4222"]
depends_on: [hub29]
hub210:
image: nats:2.10.29-alpine
command: ["-c", "/etc/nats/hub.conf", "--server_name", "hub210"]
volumes: ["./hub.conf:/etc/nats/hub.conf:ro"]
ports: ["14863:4222"]
leaf29x210:
<<: *leaf
image: nats:2.9.25-alpine
command: ["-c", "/etc/nats/leaf.conf", "--server_name", "leaf29x210"]
environment: { HUB: "nats-leaf://hub210:7422" }
ports: ["14864:4222"]
depends_on: [hub210]
hub211:
image: nats:2.11.17-alpine
command: ["-c", "/etc/nats/hub.conf", "--server_name", "hub211"]
volumes: ["./hub.conf:/etc/nats/hub.conf:ro"]
ports: ["14865:4222"]
leaf29x211:
<<: *leaf
image: nats:2.9.25-alpine
command: ["-c", "/etc/nats/leaf.conf", "--server_name", "leaf29x211"]
environment: { HUB: "nats-leaf://hub211:7422" }
ports: ["14866:4222"]
depends_on: [hub211]
hub215:
image: nats:2.15.3-alpine
command: ["-c", "/etc/nats/hub.conf", "--server_name", "hub215"]
volumes: ["./hub.conf:/etc/nats/hub.conf:ro"]
ports: ["14867:4222"]
leaf29x215:
<<: *leaf
image: nats:2.9.25-alpine
command: ["-c", "/etc/nats/leaf.conf", "--server_name", "leaf29x215"]
environment: { HUB: "nats-leaf://hub215:7422" }
ports: ["14868:4222"]
depends_on: [hub215]
guarded29:
image: nats:2.9.25-alpine
command: ["-c", "/etc/nats/leaf.conf", "--server_name", "guarded29"]
environment: { HUB: "nats-leaf://hub215:7422" }
volumes: ["./leaf-guarded.conf:/etc/nats/leaf.conf:ro"]
ports: ["14869:4222"]
depends_on: [hub215]
solo29:
image: nats:2.9.25-alpine
command: ["-js", "--server_name", "solo29"]
ports: ["14870:4222"]
The hubs and the leaf nodes share two small configurations. A leaf node reads its hub's address from the HUB variable that Compose sets:
# hub.conf: JetStream under the domain "hub", and a port for leaf nodes.
port: 4222
jetstream {
domain: hub
store_dir: "/data"
}
leafnodes {
port: 7422
}
# leaf.conf: a leaf node of the hub in $HUB, with no JetStream of its own.
port: 4222
leafnodes {
remotes: [
{ url: $HUB }
]
}
The project needs only the transport:
{
"require": {
"idct/symfony-nats-messenger": "^5.16"
}
}
lib.php holds the map of which server fronts which, and the helpers. api() sends one raw JetStream API request, labels() reads a stream's metadata straight from the server that holds it, and setup() runs the transport's setup() through a leaf node with jetstream_domain=hub, or on solo29 without it:
<?php
// What the examples share. api() sends one raw JetStream API request, as any other tool
// does; labels() reads a stream's metadata back from the hub that holds it; setup() runs
// the transport's setup() through the server the transport connects to.
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use Composer\InstalledVersions;
use IDCT\NatsMessenger\NatsTransport;
use IDCT\NatsMessenger\Options\NatsTransportConfigurationBuilder;
use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer;
/** Where the transport connects => where its JetStream is (see compose.yaml). */
const PAIRS = [
'leaf215' => 'hub29',
'leaf29x210' => 'hub210',
'leaf29x211' => 'hub211',
'leaf29x215' => 'hub215',
'solo29' => 'solo29',
];
const PORTS = [
'hub29' => 14861, 'leaf215' => 14862, 'hub210' => 14863, 'leaf29x210' => 14864,
'hub211' => 14865, 'leaf29x211' => 14866, 'hub215' => 14867, 'leaf29x215' => 14868,
'guarded29' => 14869, 'solo29' => 14870,
];
function client(string $server, string $user = ''): mixed
{
$port = PORTS[$server];
$client = (new NatsTransportConfigurationBuilder())
->build("nats-jetstream://{$user}127.0.0.1:$port/x/x")->client;
$client->connect()->await();
return $client;
}
/** The name and release the server gives when a client connects to it. */
function server(string $server, string $user = ''): string
{
$client = client($server, $user);
try {
$info = $client->serverInfo();
return "$info->serverName $info->version";
} finally {
$client->disconnect()->await();
}
}
/** One JetStream API request ($JS.API. or another prefix), its reply decoded. */
function api(string $server, string $subject, ?object $body = null,
string $prefix = '$JS.API.'): object
{
$client = client($server);
try {
$payload = $body === null ? '' : json_encode($body, JSON_THROW_ON_ERROR);
$reply = $client->request($prefix . $subject, $payload)->await();
return json_decode($reply->payload, false, 512, JSON_THROW_ON_ERROR);
} finally {
$client->disconnect()->await();
}
}
function versions(): void
{
printf(
"symfony-nats-messenger %s, php-nats-jetstream-client %s\n",
InstalledVersions::getPrettyVersion('idct/symfony-nats-messenger'),
InstalledVersions::getPrettyVersion('idct/php-nats-jetstream-client'),
);
}
/** The stream's metadata as its JetStream holds it, less the server's _nats. entries. */
function labels(string $server, string $stream): string
{
$info = api($server, "STREAM.INFO.$stream");
if (isset($info->error)) {
return "no stream $stream";
}
$own = [];
foreach ((array) ($info->config->metadata ?? []) as $name => $value) {
if (!str_starts_with((string) $name, '_nats.')) {
$own[$name] = $value;
}
}
ksort($own);
return json_encode((object) $own, JSON_UNESCAPED_SLASHES);
}
/** Runs setup() of a transport on $stream through $server, with the options given. */
function setup(string $server, string $stream, array $options, string $user = ''): string
{
$port = PORTS[$server];
$dsn = "nats-jetstream://{$user}127.0.0.1:$port/$stream/$stream.created";
if ($server !== 'solo29') {
// Every other server is a leaf node: the stream lives on its hub.
$dsn .= '?jetstream_domain=hub';
}
try {
$transport = new NatsTransport($dsn, $options, new PhpSerializer());
try {
$transport->setup();
} finally {
$transport->close();
}
return 'done';
} catch (Throwable $e) {
return (new ReflectionClass($e))->getShortName() . ': ' . $e->getMessage();
}
}
/** Prints a line, wrapped under 90 characters, the indent of the next lines included. */
function out(string $line, string $indent = ' '): void
{
echo wordwrap(rtrim($line), 88 - strlen($indent), "\n" . $indent, true), "\n";
}
Start it:
docker compose up --detach
composer install
What each JetStream reports
levels.php sends the request 5.16.0 sends, through each leaf node, and prints the level that comes back:
<?php
// The JetStream API level (ADR-44) that 5.16.0 asks for before it refuses
// stream_metadata on a server before 2.10. Through a leaf node the request goes to the
// hub's JetStream, under the domain. Run: php levels.php
declare(strict_types=1);
require __DIR__ . '/lib.php';
foreach (PAIRS as $via => $holder) {
$prefix = $via === $holder ? '$JS.API.' : '$JS.hub.API.';
$info = api($via, 'INFO', null, $prefix);
$level = isset($info->api->level) ? "API level {$info->api->level}" : 'no API level';
echo server($via), " asks {$prefix}INFO\n";
out(' the JetStream of ' . server($holder) . " answers: $level");
}
php levels.php:
leaf215 2.15.3 asks $JS.hub.API.INFO
the JetStream of hub29 2.9.25 answers: no API level
leaf29x210 2.9.25 asks $JS.hub.API.INFO
the JetStream of hub210 2.10.29 answers: no API level
leaf29x211 2.9.25 asks $JS.hub.API.INFO
the JetStream of hub211 2.11.17 answers: API level 1
leaf29x215 2.9.25 asks $JS.hub.API.INFO
the JetStream of hub215 2.15.3 answers: API level 5
solo29 2.9.25 asks $JS.API.INFO
the JetStream of solo29 2.9.25 answers: no API level
The request leaves the 2.9.25 leaf nodes under the domain and is answered by the hub, so the leaf node's own release no longer matters. 2.9.25 and 2.10.29 report no level, 2.11.17 reports 1 and 2.15.3 reports 5. That is the whole rule 5.16.0 applies: any level at all proves 2.11 or later.
5.15.0 and 5.16.0 side by side
leaf.php deletes the stream billing on the server that holds it, runs setup() with stream_metadata: { team: billing } through each pair twice, and reads the labels back from the hub:
<?php
// setup() with stream_metadata through each pair of compose.yaml: four leaf nodes under
// jetstream_domain=hub, whose stream lives on the hub, and solo29 with JetStream of its
// own. The stream is deleted first, then set up twice. Run: php leaf.php
declare(strict_types=1);
require __DIR__ . '/lib.php';
versions();
$team = ['stream_metadata' => ['team' => 'billing']];
foreach (PAIRS as $via => $holder) {
echo 'through ', server($via), ', the stream on ', server($holder), "\n";
api($holder, 'STREAM.DELETE.billing');
$first = setup($via, 'billing', $team);
out(" setup, stream_metadata: { team: billing }: $first");
$second = setup($via, 'billing', $team);
out(' setup again: ' . ($second === $first ? 'the same' : $second));
out(" billing on $holder: " . labels($holder, 'billing'), ' ');
}
php leaf.php on 5.15.0:
symfony-nats-messenger v5.15.0, php-nats-jetstream-client v2.42.1
through leaf215 2.15.3, the stream on hub29 2.9.25
setup, stream_metadata: { team: billing }: done
setup again: the same
billing on hub29: {}
through leaf29x210 2.9.25, the stream on hub210 2.10.29
setup, stream_metadata: { team: billing }: RuntimeException: The 'stream_metadata'
option requires NATS Server >= 2.10, but the connected server reports 2.9.25, which
would drop it. Remove stream_metadata or upgrade NATS.
setup again: the same
billing on hub210: no stream billing
through leaf29x211 2.9.25, the stream on hub211 2.11.17
setup, stream_metadata: { team: billing }: RuntimeException: The 'stream_metadata'
option requires NATS Server >= 2.10, but the connected server reports 2.9.25, which
would drop it. Remove stream_metadata or upgrade NATS.
setup again: the same
billing on hub211: no stream billing
through leaf29x215 2.9.25, the stream on hub215 2.15.3
setup, stream_metadata: { team: billing }: RuntimeException: The 'stream_metadata'
option requires NATS Server >= 2.10, but the connected server reports 2.9.25, which
would drop it. Remove stream_metadata or upgrade NATS.
setup again: the same
billing on hub215: no stream billing
through solo29 2.9.25, the stream on solo29 2.9.25
setup, stream_metadata: { team: billing }: RuntimeException: The 'stream_metadata'
option requires NATS Server >= 2.10, but the connected server reports 2.9.25, which
would drop it. Remove stream_metadata or upgrade NATS.
setup again: the same
billing on solo29: no stream billing
And on 5.16.0:
symfony-nats-messenger v5.16.0, php-nats-jetstream-client v2.42.1
through leaf215 2.15.3, the stream on hub29 2.9.25
setup, stream_metadata: { team: billing }: RuntimeException: The 'stream_metadata'
option requires NATS Server >= 2.10, but after the create the stream 'billing' lacks
the entries it sets (team): the JetStream that holds it (on a leaf node under
jetstream_domain, the hub's) is older than 2.10 and dropped them. Remove
stream_metadata or upgrade NATS.
setup again: the same
billing on hub29: {}
through leaf29x210 2.9.25, the stream on hub210 2.10.29
setup, stream_metadata: { team: billing }: RuntimeException: The 'stream_metadata'
option requires NATS Server >= 2.10, but the connected server reports 2.9.25, which
would drop it, and the JetStream of this account reports no API level (1 or more
shows NATS 2.11 or later). Remove stream_metadata or upgrade NATS.
setup again: the same
billing on hub210: no stream billing
through leaf29x211 2.9.25, the stream on hub211 2.11.17
setup, stream_metadata: { team: billing }: done
setup again: the same
billing on hub211: {"team":"billing"}
through leaf29x215 2.9.25, the stream on hub215 2.15.3
setup, stream_metadata: { team: billing }: done
setup again: the same
billing on hub215: {"team":"billing"}
through solo29 2.9.25, the stream on solo29 2.9.25
setup, stream_metadata: { team: billing }: RuntimeException: The 'stream_metadata'
option requires NATS Server >= 2.10, but the connected server reports 2.9.25, which
would drop it, and the JetStream of this account reports no API level (1 or more
shows NATS 2.11 or later). Remove stream_metadata or upgrade NATS.
setup again: the same
billing on solo29: no stream billing
What to look at:
- 2.9.25 leaf nodes in front of 2.11.17 and 2.15.3 hubs were refused by 5.15.0 and are set up by 5.16.0, with
{"team":"billing"}on the hub. This is the case the fix opens up. - A 2.15.3 leaf node in front of the 2.9.25 hub reported
donetwice on 5.15.0, and the stream on the hub has no labels. 5.16.0 fails after the create and names the entry that is missing. The stream exists by then, as a setup without the option would leave it, and the second setup fails the same way: the hub answers the second create with the stream as it is. - A 2.9.25 leaf node in front of the 2.10.29 hub is refused by both releases. The hub could hold the label, but it reports no level, and the message now says so.
solo29, a 2.9.25 server with no leaf node, is refused by both, after that one request in 5.16.0. The message keeps its first words, so a log alert that matchesThe 'stream_metadata' option requires NATS Server >= 2.10still matches.
A user who may not ask for the level
The level read is a publish to $JS.API.INFO, or $JS.hub.API.INFO under the domain. 5.16.0 sends it only where the option would otherwise be refused, on a connected server before 2.10, and the README's list of permissions now names it for that case. leaf-guarded.conf is the leaf node configuration with one user who may publish anywhere but there:
# leaf-guarded.conf: leaf.conf with one user, "app", who may publish anywhere except
# to the subject that asks the hub's JetStream for its API level.
port: 4222
authorization {
users: [
{
user: app
password: app
permissions: {
publish: { allow: [">"], deny: ["$JS.hub.API.INFO"] }
}
}
]
}
leafnodes {
remotes: [
{ url: $HUB }
]
}
guarded.php runs the same setup through that leaf node as app:
<?php
// A leaf node of 2.9.25 in front of a hub of 2.15.3, as the user "app", who may publish
// anywhere but $JS.hub.API.INFO (leaf-guarded.conf). Run: php guarded.php
declare(strict_types=1);
require __DIR__ . '/lib.php';
versions();
echo 'through ', server('guarded29', 'app:app@'), ' as app, the stream on ',
server('hub215'), "\n";
api('hub215', 'STREAM.DELETE.billing');
$team = ['stream_metadata' => ['team' => 'billing']];
out(' setup, stream_metadata: { team: billing }: '
. setup('guarded29', 'billing', $team, 'app:app@'));
out(' billing on hub215: ' . labels('hub215', 'billing'), ' ');
php guarded.php on 5.15.0:
symfony-nats-messenger v5.15.0, php-nats-jetstream-client v2.42.1
through guarded29 2.9.25 as app, the stream on hub215 2.15.3
setup, stream_metadata: { team: billing }: RuntimeException: The 'stream_metadata'
option requires NATS Server >= 2.10, but the connected server reports 2.9.25, which
would drop it. Remove stream_metadata or upgrade NATS.
billing on hub215: no stream billing
On 5.16.0:
symfony-nats-messenger v5.16.0, php-nats-jetstream-client v2.42.1
through guarded29 2.9.25 as app, the stream on hub215 2.15.3
setup, stream_metadata: { team: billing }: RuntimeException: The 'stream_metadata'
option requires NATS Server >= 2.10, but the connected server reports 2.9.25, which
would drop it, and the JetStream API level could not be read (The server refused the
request to "$JS.hub.API.INFO": Permissions Violation for Publish to
"$JS.hub.API.INFO". No responder received it. Grant this connection's user
permission to publish to "$JS.hub.API.INFO"). Remove stream_metadata or upgrade
NATS.
billing on hub215: no stream billing
Refused on both, as the release notes say: the hub behind this leaf node is 2.15.3 and would keep the label, but without the level the transport cannot know it. 5.16.0 tells you which subject to grant. With the grant, this is the leaf29x215 case above, which sets up.
What the upgrade does to a deploy with auto_setup
The hub-before-2.10 case turns a quiet success into an error, and that can reach your senders. With auto_setup, the transport runs setup() before the first send or get of a process. upgrade.php sends one message through leaf215, whose 2.9.25 hub drops metadata:
<?php
// One send with auto_setup through leaf215 (2.15.3), whose hub29 (2.9.25) holds the
// stream and drops metadata: auto_setup runs setup() before the first send of a process.
// Run: php upgrade.php
declare(strict_types=1);
require __DIR__ . '/lib.php';
use IDCT\NatsMessenger\NatsTransport;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer;
versions();
api('hub29', 'STREAM.DELETE.billing');
$transport = new NatsTransport(
'nats-jetstream://127.0.0.1:14862/billing/billing.created?jetstream_domain=hub',
['auto_setup' => true, 'stream_metadata' => ['team' => 'billing']],
new PhpSerializer(),
);
try {
$transport->send(new Envelope(new stdClass()));
$result = 'sent';
} catch (Throwable $e) {
$result = (new ReflectionClass($e))->getShortName() . ': ' . $e->getMessage();
} finally {
$transport->close();
}
out("send through leaf215, auto_setup, stream_metadata: { team: billing }: $result");
$info = api('hub29', 'STREAM.INFO.billing');
out(' billing on hub29: ' . (isset($info->error) ? 'no stream billing'
: labels('hub29', 'billing') . ", {$info->state->messages} message(s)"));
php upgrade.php on 5.15.0:
symfony-nats-messenger v5.15.0, php-nats-jetstream-client v2.42.1
send through leaf215, auto_setup, stream_metadata: { team: billing }: sent
billing on hub29: {}, 1 message(s)
On 5.16.0:
symfony-nats-messenger v5.16.0, php-nats-jetstream-client v2.42.1
send through leaf215, auto_setup, stream_metadata: { team: billing }:
RuntimeException: The 'stream_metadata' option requires NATS Server >= 2.10, but
after the create the stream 'billing' lacks the entries it sets (team): the
JetStream that holds it (on a leaf node under jetstream_domain, the hub's) is older
than 2.10 and dropped them. Remove stream_metadata or upgrade NATS.
billing on hub29: {}, 0 message(s)
On 5.15.0 the message was stored, on a stream without its label. On 5.16.0 the send throws and nothing is stored. So if you run a hub before 2.10 behind a newer leaf node, with stream_metadata and auto_setup both set, upgrading stops your senders until you remove the option or upgrade the hub. Without auto_setup a send does not run setup(), and the failure shows up in messenger:setup-transports instead, on every run. Issue #204 calls both topologies rare, and we agree; this is the one place where 5.16.0 can break something that ran before.
Also in 5.16.0
- Typed readers for JetStream answers (#129, internal). The consumer's
max_deliver, filters, replay policy and description, and the stream's retention, replicas and cluster, are now read through php-nats-jetstream-client's typed accessors instead of narrowing the raw arrays by hand. The release notes list no behavior change. - The repository's
leaf-node.phpexample no longer fails now and then (#182). It read the queue depth right after plain ACKs, which nothing waits for. It now waits for the count to reach 0, and a lost ACK still fails it. - README, "Keeping a message Symfony gives up on" (#128). In symfony mode, a message Symfony gives up on is TERMed, and a TERM removes it from a work-queue or interest stream. The new part describes the two setups that keep it: a failure transport on a NATS stream of its own, with a table of what Symfony's commands do there (
messenger:statsandmessenger:consume failedwork,messenger:failed:retrywithout ids takes one message per run in an interactive terminal, andmessenger:failed:show,messenger:failed:removeand a retry by id are refused), and a stream with limits retention. - The lists of feature files in
STRUCTURE.mdandtests/functional/README.mdnow namenats_retry_via_consumer_info.featureandnats_inbox_prefix.feature(#186).
Upgrading
composer update idct/symfony-nats-messenger
The client floor stays at php-nats-jetstream-client 2.39.1. Then, from the README's upgrade section and our runs:
- No leaf node, or a leaf node and a hub that both run 2.10 or later: nothing changes, and no new request goes out.
- A leaf node before 2.10 in front of a hub of 2.11 or later:
stream_metadatanow works. The transport's user needs to publish to$JS.<domain>.API.INFO, or the setup is refused as before. - A 2.9 leaf node in front of a 2.10 hub: still refused. Run the leaf node on 2.10 or later.
- A hub before 2.10 behind a leaf node of 2.10 or later:
setup()now fails after the write, every time, and withauto_setupthe first send or get of each process fails with it. Removestream_metadataor upgrade the hub before you upgrade the transport.
How it is tested
The README counts 1976 unit tests at about 99.8% coverage and a mutation score of 98.6%. The fix comes with tests such as testSetupGoesOnWithStreamMetadataWhenTheJetStreamReportsALevelThoughTheConnectedServerIsOlder, testSetupFailsWhenTheWrittenStreamLacksTheEntriesStreamMetadataSets and testStreamMetadataAndScheduledMessagesReadTheApiLevelOncePerConnection, the last of which covers the read shared with scheduled_messages. The README is plain about the gap: a leaf node and a hub on different releases were measured by hand for #204, not tested, because the test hub and its leaf node run one release. The Compose project above is that measurement, in a form anyone can rerun.
Get it
- Source and issues: symfony-nats-messenger on GitHub, with the v5.16.0 release notes and issue #204.
- Install:
composer require idct/symfony-nats-messenger, from Packagist. - Our symfony-nats-messenger software page lists what it does and what it needs.