Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/olivere/nats-streaming-server-example

An example of using a local NATS Streaming Server cluster for pub/sub.
https://github.com/olivere/nats-streaming-server-example

golang-examples nats nats-streaming-server pubsub

Last synced: 7 days ago
JSON representation

An example of using a local NATS Streaming Server cluster for pub/sub.

Awesome Lists containing this project

README

        

# NATS Streaming Server example

This example illustrates how to run a local cluster of
NATS streaming servers doing some pub/sub.

## Prerequisites

The example has been tested with NATS streaming server 0.15.1
and Go 1.11.6.

## Nutshell

Open 1st console:

```
$ nats-streaming-server -c a.conf
...
```

Open 2nd console:

```
$ nats-streaming-server -c b.conf
...
```

Open 3rd console:

```
$ nats-streaming-server -c c.conf
...
```

Open 4th console to compile and run a producer of messages
being sent to the cluster:

```
$ make
$ ./pub
...
```

Open 5th console to run a first consumer of messages:

```
$ ./sub
...
```

Open 6th console to run a second consumer of messages:

```
$ ./sub
...
```

As the consumers work as a consumer group, only one of the
consumers gets a message. This is in contrast to a normal
subscription model where each consumer gets a copy of each
message.

# Licenses

MIT