##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 twitterThen check if was successfully created:
$ docker network lsDownload Redis image
$ docker pull redis:4.0.9-alpineThen check if was successfully downloaded:
$ docker imagesRun the container:
$ docker run -d --name redis --net twitter -p 6379:6379 redis:4.0.9-alpineOpen PowerShell as Administrator and run:
$ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-LinuxRestart 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 -yConnect with the server. First discover docker machine ip:
$ docker-machine ipThen 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: 6379Run the application with maven:
$ mvn spring-boot:runCreate the docker image
$ mvn clean install docker:buildCheck for image:
$ docker imagesRun the container
$ docker run -d --name tracked-hashtag --net twitter -p 9090:9090 filipebezerra/tracked-hashtagNow 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-tagUsing curl and jq to GET something:
$ curl http://_MACHINE_IP_:9090/api/tracked-hash-tag | jq '.'