Source and Mirror configuration example
Streams with source and mirror configurations are best managed through a client API. If you intend to create such a configuration from command line with NATS CLI you should use a JSON configuration.
nats stream add --config stream_with_sources.json
Example stream configuration with two sources
Minimal example
{
"name": "SOURCE_TARGET",
"subjects": [
"foo1.ext.*",
"foo2.ext.*"
],
"discard": "old",
"duplicate_window": 120000000000,
"sources": [
{
"name": "SOURCE1_ORIGIN",
},
],
"deny_delete": false,
"sealed": false,
"max_msg_size": -1,
"allow_rollup_hdrs": false,
"max_bytes": -1,
"storage": "file",
"allow_direct": false,
"max_age": 0,
"max_consumers": -1,
"max_msgs_per_subject": -1,
"num_replicas": 1,
"name": "SOURCE_TARGET",
"deny_purge": false,
"compression": "none",
"max_msgs": -1,
"retention": "limits",
"mirror_direct": false
}
With additional options
{
"name": "SOURCE_TARGET",
"subjects": [
"foo1.ext.*",
"foo2.ext.*"
],
"discard": "old",
"duplicate_window": 120000000000,
"sources": [
{
"name": "SOURCE1_ORIGIN",
"filter_subject": "foo1.bar",
"opt_start_seq": 42,
"external": {
"deliver": "",
"api": "$JS.domainA.API"
},
},
{
"name": "SOURCE2_ORIGIN",
"filter_subject": "foo2.bar"
}
],
"consumer_limits": {
},
"deny_delete": false,
"sealed": false,
"max_msg_size": -1,
"allow_rollup_hdrs": false,
"max_bytes": -1,
"storage": "file",
"allow_direct": false,
"max_age": 0,
"max_consumers": -1,
"max_msgs_per_subject": -1,
"num_replicas": 1,
"name": "SOURCE_TARGET",
"deny_purge": false,
"compression": "none",
"max_msgs": -1,
"retention": "limits",
"mirror_direct": false
}
Example stream configuration with mirror
Minimal example
{
"name": "MIRROR_TARGET"
"discard": "old",
"mirror": {
"name": "MIRROR_ORIGIN"
},
"deny_delete": false,
"sealed": false,
"max_msg_size": -1,
"allow_rollup_hdrs": false,
"max_bytes": -1,
"storage": "file",
"allow_direct": false,
"max_age": 0,
"max_consumers": -1,
"max_msgs_per_subject": -1,
"num_replicas": 1,
"name": "MIRROR_TARGET",
"deny_purge": false,
"compression": "none",
"max_msgs": -1,
"retention": "limits",
"mirror_direct": false
}
With additional options
{
"name": "MIRROR_TARGET"
"discard": "old",
"mirror": {
"opt_start_time": "2024-07-11T08:57:20.4441646Z",
"external": {
"deliver": "",
"api": "$JS.domainB.API"
},
"name": "MIRROR_ORIGIN"
},
"consumer_limits": {
},
"deny_delete": false,
"sealed": false,
"max_msg_size": -1,
"allow_rollup_hdrs": false,
"max_bytes": -1,
"storage": "file",
"allow_direct": false,
"max_age": 0,
"max_consumers": -1,
"max_msgs_per_subject": -1,
"num_replicas": 1,
"name": "MIRROR_TARGET",
"deny_purge": false,
"compression": "none",
"max_msgs": -1,
"retention": "limits",
"mirror_direct": false
}