Demonstrates eventing retries and delivery to a DLQ.
Contains a single event called TestEvent, generated from a json-schema.
Contains a RestController
which listens for POSTs to /message
and dispatches
a TestEvent
for every request handled.
Contains an ExampleService
class which implements EventHandler<TestEvent>
.
The handle
method therein logs a message every time it is invoked and then
throws a RuntimeException
.
After five failed attempts to handle the TestEvent
, it is forwarded to the
queue custom.test-event.dlq
.
The max attempts and DLQ name are both configured in the application.yml for
the service. Removing this configuration will result in the failed messages
being forwarded to the queue Spring.Cloud.Stream.dlq
after three failed
attempts.
You will need an ActiveMQ server running on localhost:61616, or you will need to configure
an ActiveMQ connection in the application.yml files of the producer
and consumer
services.
- In the
event-spec
dir, runmvn clean install
to generate the TestEvent object and associated autoconfiguration class. - In the
consumer
dir, runmvn clean spring-boot:run
to start the consumer service. - In the
producer
dir, runmvn clean spring-boot:run
to start the producer service. - Send a post to http://localhost:9915/message with the following request body:
{ "message": "Hello" }
- The logs for the
consumer
service should show the handler was invoked five times, with an increasing backoff.