Skip to content

Instantly share code, notes, and snippets.

@rubysolo
Created February 15, 2019 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubysolo/ab8b8c9a936b76373734c080df818988 to your computer and use it in GitHub Desktop.
Save rubysolo/ab8b8c9a936b76373734c080df818988 to your computer and use it in GitHub Desktop.
NATS multi-tenant

Running multi-tenant NATS server

Requires NATS 2.x, which is currently unreleased, so must be built from master.

connect to the same queue name under multiple accounts:

session 1:

nats-sub -s nats://quser1:one@$NATS_SERVER:$NATS_PORT 'foo'

session 2:

nats-sub -s nats://quser2:two@$NATS_SERVER:$NATS_PORT 'foo'

session 3:

nats-pub -s nats://quser1:one@$NATS_SERVER:$NATS_PORT 'foo' hey

Message is received on session one, but not session two.

# ... stock conf from the git repo, then add:
accounts: {
env1: {
users = [
{user: quser1, password: one}
]
}
env2: {
users = [
{user: quser2, password: two}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment