We assume that xbus binaries are already installed in your path. If not, you can download them from xbus download page.

Setup a server

Write a configuration file (possibly in /etc/xbus/xbusd.yaml):

mkdir -p ~/.config/xbus
cat > ~/.config/xbus/xbusd.yaml <<EOF
  dsn: dbname=xbus user=xbus password=xbus

From the CWD in which the server will run, initialize the certdir (future version will not need this step):

mkdir -p certs/xbusd

Initialize the database:

xbusd init

Initialize the keys and certs:

xbusd key generate
xbusd cert generate server-ca --host-defs localhost
xbusd cert generate client-ca

Run it:

xbusd serve

Setup a ctl client

Setup the conf && generate a key:

xbusctl --account-name myname key generate

You can check the result in ~/.config/xbus/myname.certs.

Registration 1st step:

xbusctl --account-name myname register

2nd step is to accept the account on the server, with xbusd (because it is the first account, next accounts should be accepted with xbusctl):

xbusd account accept myname

3rd and last step, let xbusctl know it has been accepted:

xbusctl --account-name myname register

Setup a client

Write a basic configuration file to initialize a new account with 1 emitter, 1 consumer and 1 worker (you can add/remove as many actors you want), and save it as “xbus-client.yaml”:

account-name: demo-client
nats-url: nats://localhost:4222/
    kind: emitter
    roles: [helloworld]
      type: demo.helloworld
        interval: 4
        message: "Hello world"
    kind: consumer
    roles: [print]
      type: demo.print-to-console
    kind: worker
    roles: [relay]
      type: demo.relay
        processing-duration: 6

Do the 1st registration step, by running xbus-client:

xbus-client --config xbus-client.yaml register

If no error occur, the account and actors are now created in a pending state on the server, and the xbus-client.yaml file was updated with their new ID, among other things.

The 2nd registration step is to accept the account an actors on the server side. It should be done with xbusctl account accept and xbusctl actor accept:

xbusctl account accept demo-client
xbusctl actor accept emitter-1
xbusctl actor accept consumer-1
xbusctl actor accept worker-1

The 3rd and last step is to let your client know that it was accepted by re-running the ‘register’ command:

xbus-client --config xbus-client.yaml register

From this point, any connection from the client will be authenticated by a TLS certificate.

You can add more actors at any time and redo the registration steps, only the new actors will be impacted (not the account or the older actors).

Make sure the client is able to start the services:

xbus-client serve

You should have some error logs like the following ones (because no pipeline has been configured yet):

[23989] [ERR] Error sending envelope: No matching pipeline
[23989] [ERR] send failed: No matching pipeline

You can hit CTRL-C to stop the client, you can also let it run until the pipeline is activated and see what happens.

Setup a pipeline

Write a pipeline file demo.yaml:

- id: relay
  type: worker
  - worker-1
  - default
  - default
- id: sink
  type: consumer
  - print
  rolebroadcast: true
  - default
- id: source
  type: emitter
    - demo.simplemessage
  - default
- source.default->relay.default
- relay.default->sink.default

Load an activate the pipeline in the bus:

xbusctl pipeline save demo 1.0 demo.yaml
xbusctl pipeline status demo 1.0 --active

Go live

Now starts the client, which will run all the actors in a single process:

xbus-client serve

You should see the various actors logging their actions.