Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docs for @KafkaClient/@KafkaListener behavior #657

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/docs/guide/kafkaClient/kafkaClientConfiguration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ kafka:
producers:
default:
retries: 5
bootstrap:
servers: localhost:9096

----

Any property in the link:{kafkaapi}/org/apache/kafka/clients/producer/ProducerConfig.html[ProducerConfig] class can be set. The above example will set the default number of times to retry sending a record.
Any property in the link:{kafkaapi}/org/apache/kafka/clients/producer/ProducerConfig.html[ProducerConfig] class can be set, _including_ any overrides over the global Micronaut Kafka configs. The above example will set the default number of times to retry sending a record as well as override `kafka.bootstrap.servers`.

=== Per @KafkaClient Producer Properties

Expand All @@ -32,6 +35,11 @@ kafka:
producers:
product-client:
retries: 5
bootstrap:
servers: localhost:9097
product-client-2:
bootstrap:
servers: localhost:9098
----

Finally, the ann:configuration.kafka.annotation.KafkaClient[] annotation itself provides a `properties` member that you can use to set producer specific properties:
Expand Down
14 changes: 14 additions & 0 deletions src/main/docs/guide/kafkaListener.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@ The above example will create 10 link:{kafkaapi}/org/apache/kafka/clients/consum
NOTE: @KafkaListener beans are by default singleton. When using multiple threads you must either synchronize access to local state or declare the bean as `@Prototype`.

By default Micronaut will inspect the method signature of the method annotated with `@Topic` that will listen for `ConsumerRecord` instances and from the types infer an appropriate key and value link:{kafkaapi}/org/apache/kafka/common/serialization/Deserializer.html[Deserializer].

.Applying Configuration
[source,yaml]
----
kafka:
consumers:
default:
allow.auto.create.topics: true
product:
bootstrap:
servers: localhost:9098
----

Any property in the link:{kafkaapi}\/org/apache/kafka/clients/consumer/ConsumerConfig.html[ConsumerConfig] class can be set for all `@KafkaListener` beans based on the . The above example will enable the consumer to create a topic if it doesn't exist for the `default` (`@KafkaListener`) client and set a custom bootstrap server for the `product` client (`@KafkaListener(value = "product")`)