How do you implement Kafka stream processing in Spring Boot?
Set up Kafka Streams in Spring Boot 3 with @EnableKafkaStreams, build topologies with StreamsBuilder, run windowed aggregations and test with TopologyTestDriver.
2,882 posts about Java: questions with answers, tutorials and articles, newest first.
Set up Kafka Streams in Spring Boot 3 with @EnableKafkaStreams, build topologies with StreamsBuilder, run windowed aggregations and test with TopologyTestDriver.
Build custom ItemReader and ItemWriter classes for Spring Batch, with restart support, the Chunk-based writer API and current StepBuilder configuration.
Use RecordFilterStrategy in Spring for Apache Kafka to drop unwanted records before your listener runs, with header, payload, batch and Kafka Streams options.
A Job is the whole batch process and a Step is one tracked phase of it. See chunk and tasklet steps, flow control and restart with current Spring Batch 5 code.
Build a chunk-oriented Spring Batch job with a reader, processor and writer, then add job parameters, skip and retry rules and options for scaling.
Use record keys, explicit partitions or a custom Partitioner on the producer, and consumer groups to read partitions in parallel with Spring Kafka.
Define one data source and transaction manager per database, select it with @Transactional, and use JTA/XA or an outbox only when you need cross-database consistency.
@Version tracks a version number on a JPA entity so conflicting updates are detected. This guide covers mapping, types, Spring Data behaviour and pitfalls.
Use @Version with Spring Data JPA, retry stale updates outside the transaction and map OptimisticLockingFailureException to a 409 ProblemDetail.
Set the spring.kafka.producer properties and inject KafkaTemplate to publish. Covers acks, idempotence, callbacks, topics and exactly-once transactions.
TransactionManager is the root of Spring's transaction abstraction, with implementations for JDBC, JPA, JTA and R2DBC behind @Transactional.
Learn the seven Spring transaction propagation types, when to use REQUIRED, REQUIRES_NEW and NESTED, and why self-invocation ignores them.
Spring's @Transactional wraps a method in a transaction that commits on success and rolls back on failure. See attributes, rollback rules and pitfalls.
Learn declarative and programmatic transactions in Spring: @Transactional, rollback rules, propagation, isolation levels and the proxy pitfalls to avoid.
ProceedingJoinPoint gives @Around advice control over a method call through proceed(). Learn timing, argument changes, retries and the limits of proxy AOP.
Use an @Aspect with @Before, @AfterReturning, @AfterThrowing and @Around advice to log method calls in Spring, with pointcuts and a custom annotation.
@Around advice surrounds a method call and controls whether, how and with what arguments it runs. Learn how it differs from other advice and when to use it.
The @Aspect annotation marks a class as an aspect that holds pointcuts and advice. See how Spring AOP uses it with proxies, plus advice types and limits.
Set spring.kafka consumer properties and add a @KafkaListener method. Covers JSON payloads, error handling, dead-letter topics and manual acknowledgement.
KafkaTemplate wraps the Kafka producer so a Spring Boot app can publish records with one call. See configuration, send overloads, result handling and transactions.