Adding a Queue Based Service
In this recipe, we will create a simple asynchronous event service. In this context asynchronous means that we will expose the service over a queue rather than a direct point to point connection.
We will be using Redis as a our queue mechanism, specifically we're using a Redis list structure with the LPUSH
and BRPOP
commands to make a FIFO queue.
Note
Redis and Node
We cover using Redis with Node in the Storing and Retrieving Data with Redis reciepe in Chapter 6, Persisting to Databases holds.
Getting ready
To prepare for this recipe we need to ensure that we have Redis available. The simplest way to do this is to use the official Docker Redis image, so, to get ready for this section we will need to pull redis
from Docker Hub:
$ docker pull redis
This recipe builds on the code in the micro
folder as we left off in the previous recipe, Service discovery with DNS.
How to do it...
Our service is going to record events of interest in the system such as page loads. In a...