Step 2 — Never processing twice

Redelivery is normal; an idempotent consumer makes it harmless.

← step 1 · step 3 →

Run it

One command, whichever language you came for. The image carries the toolchain, the library and RabbitMQ; the management UI is on http://localhost:15672 (guest/guest) while it runs, and --keep holds it open afterwards.

docker run --rm -p 15672:15672 ghcr.io/acemq-company/acemq-tutorials-java:0.7.15 step 2
docker run --rm -p 15672:15672 ghcr.io/acemq-company/acemq-tutorials-python:0.7.12 step 2
docker run --rm -p 15672:15672 ghcr.io/acemq-company/acemq-tutorials-ruby:0.7.14 step 2
docker run --rm -p 15672:15672 ghcr.io/acemq-company/acemq-tutorials-dotnet:0.7.13 step 2
docker run --rm -p 15672:15672 ghcr.io/acemq-company/acemq-tutorials-go:0.9.9 step 2

Side by side

Java Python Ruby .NET Go
Example 05-idempotent-consumer 02-idempotent-consumer 02-idempotent-consumer 03-idempotent-consumer-csharp 02-idempotent-consumer
Tutorial: exactly once Java Python Ruby .NET Go
Reliability Java Python Ruby .NET Go

Java

acemq-java-amqp 0.7.15, acemq-java-amqp-examples examples-v0.7.15.

basic/05-idempotent-consumer

Every broker worth using delivers at least once. Duplicates are normal traffic, not an error, and handling one twice is your problem to prevent.

Python

acemq-python-amqp 0.7.12, acemq-python-amqp-examples examples-v0.7.12.

intermediate/02-idempotent-consumer

One logical payment delivered four times and charged once — and still once after a restart.

Ruby

acemq-ruby-amqp 0.7.14, acemq-ruby-amqp-examples examples-v0.7.14.

intermediate/02-idempotent-consumer

One logical message delivered four times, and one charge.

.NET

acemq-dotnet-amqp 0.7.13, acemq-dotnet-amqp-examples examples-v0.7.13.

basic/03-idempotent-consumer-csharp

One logical charge published three times under the same message id, its first delivery failed on purpose so the broker sends it again, and a consumer with an idempotency store in front of the handler that lets exactly one of them through to the card — because retries and at-least-once producers mean a message can arrive more than once, and a handler that changes anything has to be able to tell.

Go

acemq-go-amqp 0.9.9, acemq-go-amqp-examples examples-v0.9.9.

intermediate/02-idempotent-consumer

One charge is published three times with the same message id, and its first delivery fails on purpose and is retried, so the consumer receives it four times — and patterns.Idempotent makes sure the card is charged exactly once.