1. Spring Boot
  2. Tutorial

Consume Messages

Run the following command to run the Spring Boot application for the Consumer.

gradle bootRun --args='--consumer'

The consumer application will start and print any events it has not yet consumed and then wait for more events to arrive. On startup of the consumer, you should see output resembling this:

2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = jsmith     value = gift card
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = sgarcia    value = gift card
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = sgarcia    value = t-shirts
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = sgarcia    value = gift card
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = sgarcia    value = book
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = sgarcia    value = gift card
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = sgarcia    value = t-shirts
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = sgarcia    value = batteries
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = htanaka    value = batteries
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = htanaka    value = book
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = awalther   value = book
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = htanaka    value = t-shirts
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = awalther   value = alarm clock
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = htanaka    value = alarm clock
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = sgarcia    value = gift card
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = sgarcia    value = t-shirts
2024-11-16T21:10:53.186-08:00  INFO 23554 --- [yConsumer-0-C-1] examples.Consumer                        : Consumed event from topic purchases: key = sgarcia    value = book

Rerun the producer to see more events, or feel free to modify the code as necessary to create more or different events.

Once you are done, enter Ctrl-C to terminate the consumer application.

Previous
Produce Messages