Skip to content

sample kafka avro producer + consumer#429

Open
etrandafir93 wants to merge 3 commits intospring-cloud-samples:mainfrom
etrandafir93:dev/kafka_avro_samples
Open

sample kafka avro producer + consumer#429
etrandafir93 wants to merge 3 commits intospring-cloud-samples:mainfrom
etrandafir93:dev/kafka_avro_samples

Conversation

@etrandafir93
Copy link
Copy Markdown

@etrandafir93 etrandafir93 commented Jan 27, 2026

Adds two new sample modules — producer_kafka_avro and consumer_kafka_avro
demonstrating how to use Spring Cloud Contract when Kafka messages are serialized with Avro (Confluent wire format).

The producer publishes a book.returned event encoded as an Avro Book object;
the consumer listens to the same topic, deserializes the message, and triggers an email notification.

Each side comes with two contract testing flavors.

  • The JSON flavor expresses the expected message as human-readable fields in the contract:
    • SCC deserializes the Avro bytes back to a Book,
    • converts it to JSON,
    • and asserts field-by-field
    • straightforward failure messages at the cost of two extra serialization round-trips.
  • The binary flavor references a pre-serialized .bin fixture
    • (generated once and committed to source control)
    • the contract compares raw bytes on the producer side,
    • the stub runner replays those exact bytes through the consumer's full deserialization stack on the consumer side
    • a stricter wire-format guarantee, but harder-to-read failure output.

@etrandafir93 etrandafir93 force-pushed the dev/kafka_avro_samples branch 2 times, most recently from ea642bb to 9dbeda0 Compare February 1, 2026 14:59
Signed-off-by: Emanuel Trandafir <emanueltrandafir1993@gmail.com>
@etrandafir93 etrandafir93 force-pushed the dev/kafka_avro_samples branch from 5875626 to d36de2b Compare April 27, 2026 15:11
Signed-off-by: Emanuel Trandafir <emanueltrandafir1993@gmail.com>
Signed-off-by: Emanuel Trandafir <emanueltrandafir1993@gmail.com>
@etrandafir93 etrandafir93 marked this pull request as ready for review April 28, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant