Configuring Subject Mapping
Supported since NATS Server version 2.2
Subject mapping is a very powerful feature of the NATS server, useful for canary deployments, A/B testing, chaos testing, and migrating to a new subject namespace.
Subject mappings are defined and applied at the account level. If you are using static account security you will need to edit the server configuration file, however if you are using JWT Security (Operator Mode), then you need to use nsc or customer tools to edit and push changes to you account.
NOTE: You can also use subject mapping as part of defining imports and exports between accounts
In any of the static authentication modes the mappings are defined in the server configuration file, any changes to mappings in the configuration file will take effect as soon as a reload signal is sent to the server process (e.g. use
nats-server --signal reload
).The
mappings
stanza can occur at the top level to apply to the global account or be scoped within a specific account.mappings = {
# Simple direct mapping. Messages published to foo are mapped to bar.
foo: bar
# remapping tokens can be done with $<N> representing token position.
# In this example bar.a.b would be mapped to baz.b.a.
bar.*.*: baz.$2.$1