##This repo contains the source code of a Twitter Message Broker application.
The back-end was written using Java with Spring Boot.
First create a docker network:
$ docker network create twitter
Then check if was successfully created:
$ docker network ls
Download Redis image
$ docker pull redis:4.0.9-alpine
Then check if was successfully downloaded:
$ docker images
Run the container:
$ docker run -d --name redis --net twitter -p 6379:6379 redis:4.0.9-alpine
Open PowerShell as Administrator and run:
$ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Restart your computer when prompted.
Install Ubuntu 18.04 from Microsoft Store or from the command-line.
Download and install using WSL
$ sudo apt install redis-tools -y
Connect with the server. First discover docker machine ip:
$ docker-machine ip
Then connect:
$ redis-cli -h _MACHINE_IP_
In the src/main/resources directory you can find a file called application.yaml
.
Open this file and enter your Redis server host and port string as directed in the comment. This is the information the driver will use to connect.
host: 192.168.99.100
port: 6379
Run the application with maven:
$ mvn spring-boot:run
Create the docker image
$ mvn clean install docker:build
Check for image:
$ docker images
Run the container
$ docker run -d --name tracked-hashtag --net twitter -p 9090:9090 filipebezerra/tracked-hashtag
Now we can test the API using Postman or curl.
Using curl to POST something:
$ curl -H "Content-Type: application/json" -X POST -d '{"hashTag": "go", "queue": "go"}' http://_MACHINE_IP_:9090/api/tracked-hash-tag
Using curl and jq to GET something:
$ curl http://_MACHINE_IP_:9090/api/tracked-hash-tag | jq '.'