About the project | Technologies | Getting started |
This project is an introductory example of how to use RabbitMQ with Java using Spring Boot. Here, we have 2 main applications, a producer and a consumer. At the producer, we have the http://localhost:8081/ send endpoint that accepts a POST request with a json that should contain a message. As in the example below:
{
"text": "teste"
}
Once this message is sent, the consumer will receive that message and process it. If the content of the "text" field is equal to "test" an error will be generated and this message will be forwarded to a queue called dl.producer.aula-spring (Dead Letter). This project also has a Schedule configured with a service that tries to republish the messages that gave an error, returning the messages to the main queue. This republish tries to resend these messages 3 times and on the 4th time it sends this message to the pl.producer.aula-spring (Parking Letter) queue, we can manually check these messages. In parallel to this schedule, we also have the possibility to activate the republish service by consuming the consumer's endpoint at http://localhost:8082/ repost with a GET request.
Clone the project and access the folder
$ git clone https://github.com/felipeDS91/rabbitmq-spring.git && cd rabbitmq-spring
Follow the steps below
# Start a RabbitMQ container using the following command
$ docker run -d -p 15672:15672 -p 5672:5672 --name rabbitmq rabbitmq:3-management
To check if the RabbitMQ is working properly, access http://localhost:15672/ e with this default credentials bellow:
username = guest
password = guest
Finally, just run both projects with the STS (Spring Tools Suite).
Made with 💜 by Felipe Douglas 👋 See my linkedin