- Make sure you read our try NLX guide.
- Make sure you have installed a recent version of Docker Compose.
- Make sure you have installed a recent version of Git.
The inway and the outway are able to log metadata of the requests they process. In this guide you will learn how to write transaction logs from the outway service.
To make the setup of the transaction logs as easy as possible, we have provided a
docker-compose.yml file in the nlx-compose repository. It contains configuration for a PostgreSQL container and executes the migrations necessary for the txlog-db.
Start by cloning the nlx-compose repository.
After pulling the repository lets navigate to the correct directory
We can now use the Docker compose configuration to start the services we need for the transaction logs.
With a SQL command we are able to view the logs in the database:
As you can see there are nog logs yet.
The next step is to connect an inway or an outway to the database. If you've followed the Try NLX guide you will either have an inway or an outway running. In this example we will connect the transaction log to the outway setup in the Try NLX guide.
If your outway from the Try NLX guide is still running, you will have to stop it first.
To connect the transaction log database to our outway we need to start the outway with a different docker command:
There are some key differences in the Docker command compared to the one used to start the outway in Try NLX.
We will go over them briefly
- We removed the flag
--env DISABLE_LOGDB=1, this flag disables the transaction-log on the outway and defeats the purpose of this guide.
- We added the flag
--env POSTGRES_DSN='postgres://postgres:postgres@postgres/txlog-db?sslmode=disable&connect_timeout=10', this flags stores the postgres connection string in the environment variable
POSTGRES_DSNon the docker container. The outway uses this connection string to setup a connection to the transaction-log database.
- We added the flag
--network nlx, this connects the docker container to the same docker network as the transaction log database (this network is created by the docker-compose-file we executed earlier). Without this parameter the outway wouldn't be able to connect to the transaction log.
Let's make a request through our outway and check if the log records are being writen.
If successful the response should be
Now the outway should have written records to the transaction log database. Let's query the transaction log API, to verify the log records were written.
Congratulations, you've connected your outway to the transaction log!