Java Spring Boot application implementing JMS and ActiveMq to track and persist application events in the database.
a) Microservice1 . event-tracker: Spring Boot application/microservice consisting of a REST API endpoint to send event messages to a queue.(Test-1)
b)event-processor: Spring Boot application/microservice which is consuming messages from the queue and persisting events int the database.(Test-2)
Queue implemented using ActiveMQ.
-
clone the project.
-
Install postgres:
brew install postgres
. -
Start postgres server
pg_ctl -D /usr/local/var/postgres start
-
psql postgres
andCREATE ROLE username WITH LOGIN PASSWORD 'quoted password';
. -
ALTER ROLE username CREATEDB;
. -
createdb event;
-
Install activemq
brew install activemq
. It will run on the default port 61616. Go tohttp://localhost:8161/admin/
to view the web console. -
go to the project directory in a new terminal.
cd event-tracker
. -
Run
mvn clean install
to check whether it compiles correctly. Then runmvn clean spring-boot run
. This will start the event tracker application/microservice which pushes event to the queue. -
Go to
http://localhost:8090/swagger-ui.html
to view the UI of the REST API. (Post endpoint) -
Populate the request parameters and execute the request.
-
Check queue status
EventTrackingQueue
in the web consolehttp://localhost:8161/admin/
. You will the see the pending message which is not consumed yet in theQueues
section. -
Now in the project structure change directory to
event-processor
module. This microservice consumes the pending message in the queue and persists it in theevent
table of postgres db setup earlier. -
mvn clean install
andmvn clean spring-boot run
Look at the event message in the console logs. -
Check ActiveMq web cosole the pending message should be consumed.
-
Check
event
table ----> the message will be peristed.
Message redelivery option configured in parent project event-tracker
> application.properties
(maximumRedeliveries=1
).