Skip to content

Commit

Permalink
review fix
Browse files Browse the repository at this point in the history
After kafka client 2.4 producer uses sticky partition, its randomly chose partition and topic default partitions is 2, configure that @embeddedkafka to provide just one partition per topic.

* javadoc in `AsyncRepliesAware`
* fix test in EnableKafkaKotlinCoroutinesTests
* polish adoc
  • Loading branch information
Wzy19930507 committed Jan 30, 2024
1 parent 92639b6 commit 2a3068e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
= Asynchronous `@KafkaListener` Return Types

`@KafkaListener` (and `@KafkaHandler`) methods can be specified with asynchronous return types, letting the reply be sent asynchronously.
return types include `CompletableFuture<?>`, `Mono<?>` and Kotlin `suspend` functions
return types include `CompletableFuture<?>`, `Mono<?>` and Kotlin `suspend` functions.

[source, java]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ See xref:kafka/transactions.adoc#transaction-id-suffix-fixed[Fixed TransactionId
[[x32-async-return]]
=== Async @KafkaListener Return

`@KafkaListener` (and `@KafkaHandler`) methods can now return asynchronous return types `CompletableFuture<?>` and `Mono<?>`.
`@KafkaListener` (and `@KafkaHandler`) methods can now return asynchronous return types include `CompletableFuture<?>`, `Mono<?>` and Kotlin `suspend` functions.
See xref:kafka/receiving-messages/async-returns.adoc[Async Returns] for more information.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,15 +17,16 @@
package org.springframework.kafka.listener.adapter;

/**
* Auto-detect {@link HandlerAdapter} return type.
* Message handler adapter implementing this interface can detect {@link HandlerAdapter} async return types.
*
* @author Wang zhiyang
*
* @since 3.2
*/
public interface AsyncRepliesAware {

/**
* Return true if this listener is request/reply and the replies are async.
* Return true if the {@link HandlerAdapter} return type is async.
* @return true for async replies.
* @since 3.2
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
* but for regular {@link HandlerMethodArgumentResolver} contract.
*
* @author Wang Zhiyang
*
* @since 3.2
*
* @see org.springframework.messaging.handler.annotation.reactive.ContinuationHandlerMethodArgumentResolver
*/
public class ContinuationHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import java.util.concurrent.TimeUnit
@SpringJUnitConfig
@DirtiesContext
@EmbeddedKafka(topics = ["kotlinAsyncTestTopic1", "kotlinAsyncTestTopic2",
"kotlinAsyncBatchTestTopic1", "kotlinAsyncBatchTestTopic2", "kotlinReplyTopic1"])
"kotlinAsyncBatchTestTopic1", "kotlinAsyncBatchTestTopic2", "kotlinReplyTopic1"], partitions = 1)
class EnableKafkaKotlinCoroutinesTests {

@Autowired
Expand Down

0 comments on commit 2a3068e

Please sign in to comment.