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.
- Build & Run
- Fork it by creation of any queue
- Bind the queue to
scheduler
exchange with a predefined routing key (e.g.minute
orsecond
)
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"}
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