Skip to content

WildDev/rabbitmq-cron

Repository files navigation

Description

RabbitMQ based cron events emitter service. It is not supposed to be scalable, so you need to run only one auto-restart replica. Well-suited for small and medium-sized apps.

Java CI with Maven Docker Image CI

How it works

  1. Build & Run
  2. Fork it by creation of any queue
  3. Bind the queue to scheduler exchange with a predefined routing key (e.g. minute or second)

Sample new-items-poll-tick-queue configuration:

rabbitmqadmin declare queue name=new-items-poll-tick-queue durable=false
rabbitmqadmin declare binding source=scheduler destination_type=queue destination=new-items-poll-tick-queue routing_key=minute

An example message to be emitted:

Exchange 	scheduler
Routing Key 	minute
...
headers:	
content_encoding:	UTF-8
content_type:	application/json
...
Payload
Encoding: string

{"timestamp":"2024-09-24 10:00:00"}

Get started

Build requirements:

  • latest JDK and Maven

Runtime stack:

  • Java 20
  • RabbitMQ 4

Checkout the project and build it using mvn package command

An example run:

java -jar -Xmx256M target/rabbitmq-cron.jar \
    --server.port=8000 \
    --spring.rabbitmq.host=rabbitmq \
    --spring.rabbitmq.port=5671 \
    --spring.rabbitmq.username=guest \
    --spring.rabbitmq.password=guest

Warning

Ensure that this service is initially started before other dependent services, as it creates durable scheduler exchange

Also available on Docker Hub

About

RabbitMQ based cron events emitter service

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published