How Do You Implement a Kafka Producer in Spring Boot?
Build a Kafka producer in Spring Boot 3 with KafkaTemplate, YAML configuration, topic creation, async callbacks and reliability settings.
2,881 posts about Java: questions with answers, tutorials and articles, newest first.
Build a Kafka producer in Spring Boot 3 with KafkaTemplate, YAML configuration, topic creation, async callbacks and reliability settings.
KafkaTemplate is Spring Kafka's producer class. See how to send records, handle the CompletableFuture result, set headers and use transactions.
Send typed JSON events between Spring Boot services with spring-kafka, KafkaTemplate and @KafkaListener, plus consumer groups, testing and production settings.
PagedModel wraps a page of results with metadata and next, prev, first and last links. Learn how PagedResourcesAssembler builds it in Spring Boot REST APIs.
Return a PagedModel from PagedResourcesAssembler so clients get first, prev, self, next and last links plus page metadata with every response.
Add self, collection and conditional links to a Spring Boot REST API with Spring HATEOAS, using EntityModel, assemblers and HAL responses.
EntityModel wraps a domain object together with hypermedia links, so Spring HATEOAS can return HAL responses that guide clients to related resources.
Add hypermedia links to a Spring Boot REST API with Spring HATEOAS, using EntityModel, CollectionModel, assemblers and linkTo on Spring Boot 3.
Authenticate the WebSocket handshake with a SecurityFilterChain and authorize STOMP messages with @EnableWebSocketSecurity in Spring Security 6.
WebSocketSession is Spring's handle for one open WebSocket connection. See its key methods, handler lifecycle, thread-safe sending and common pitfalls.
Extend TextWebSocketHandler, enable WebSocket support and register the handler on a path. Includes origin security, broadcasting and a browser client.
@EnableWebSocket registers WebSocketHandler endpoints in Spring. Build an echo handler, secure origins and compare it with STOMP messaging.
Classify failures, configure retry and skip, record rejects and alert on metrics so high-frequency Spring Batch jobs detect faults without manual log reading.
Validate in layers: structure in the reader, field rules in the processor, and cross-record checks with set-based SQL, with bounded skips and an audit trail.
Adapt Spring Batch jobs to changing data volumes with a JobExecutionDecider, tunable chunk size and a partitioned step on a thread pool.
Work back from the deadline: measure each step, partition and parallelise the critical path, tune chunk size, and alert before the SLA is at risk.
Schedule Spring Batch jobs, bound chunks with transaction timeouts, stop steps at a deadline with a listener, and alert when time-critical runs are late.
Split a Spring Batch step across worker JVMs with a Partitioner and a message broker, and restart failed partitions from a shared job repository.
ResponseErrorHandler decides which HTTP responses RestTemplate treats as errors and how they are reported. See the default behaviour and a custom handler.
Use identifying job parameters, bounded executors and the right lock type to run Spring Batch jobs for many users at once without duplicates or conflicts.