Skip to content

Commit

Permalink
Use Micronaut 3.0 M4. Update annotation docs (#395)
Browse files Browse the repository at this point in the history
* Use M4. Update annotation docs

* fix failing test

Co-authored-by: graemerocher <graeme.rocher@gmail.com>
  • Loading branch information
jameskleeh and graemerocher authored Jul 26, 2021
1 parent ee1ed0f commit 93c571b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
9 changes: 4 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
projectVersion=4.0.0-SNAPSHOT
micronautDocsVersion=2.0.0.RC1
micronautBuildVersion=1.1.5
micronautVersion=3.0.0-SNAPSHOT
micronautGradlePluginVersion=1.5.0
groovyVersion=3.0.5
spockVersion=2.0-M3-groovy-3.0
micronautVersion=3.0.0-M4
micronautGradlePluginVersion=2.0.2
groovyVersion=3.0.8
spockVersion=2.0-groovy-3.0
kafkaVersion=2.8.0
testContainersVersion=1.15.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class KafkaListenerSpec extends AbstractEmbeddedServerSpec {
}
}
void "test @Body annotation"() {
void "test @MessageBody annotation"() {
when:
MyClient myClient = context.getBean(MyClient)
RecordMetadata metadata = myClient.sendGetRecordMetadata("key", "hello world")
Expand Down Expand Up @@ -182,7 +182,7 @@ class KafkaListenerSpec extends AbstractEmbeddedServerSpec {
producer?.close()
}
void "test @Header annotation with optional"() {
void "test @MessageHeader annotation with optional"() {
when:
MyClient myClient = context.getBean(MyClient)
myClient.sendSentence("key", "Hello, world!", "words")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class KafkaProducerSpec extends AbstractKafkaSpec {

def setupSpec() {
kafkaContainer.start()
context = ApplicationContext.build(
context = ApplicationContext.builder(
getConfiguration() +
['micronaut.application.name' : 'test-app',
"kafka.schema.registry.url" : "http://localhot:8081",
Expand Down
16 changes: 8 additions & 8 deletions src/main/docs/guide/kafkaClient/kafkaClientMethods.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Kafka key can be specified by providing a parameter annotated with `@KafkaKey`. If no such parameter is specified the record is sent with a `null` key.

The value to send is resolved by selecting the argument annotated with https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/Body.html[@Body], otherwise the first argument with no specific binding annotation is used. For example:
The value to send is resolved by selecting the argument annotated with https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/MessageBody.html[@MessageBody], otherwise the first argument with no specific binding annotation is used. For example:

[source,java]
----
Expand All @@ -14,15 +14,15 @@ The method above will use the parameter `brand` as the key and the parameter `na

=== Including Message Headers

There are a number of ways you can include message headers. One way is to annotate an argument with the https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/Header.html[@Header] annotation and include a value when calling the method:
There are a number of ways you can include message headers. One way is to annotate an argument with the https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/MessageHeader.html[@MessageHeader] annotation and include a value when calling the method:

[source,java]
----
@Topic("my-products")
void sendProduct(
@KafkaKey String brand,
String name,
@Header("My-Header") String myHeader);
@MessageHeader("My-Header") String myHeader);
----

The example above will include the value of the `myHeader` argument as a header called `My-Header`.
Expand Down Expand Up @@ -124,13 +124,13 @@ The following table summarizes the annotations and their purpose, with an exampl
|===
|Annotation |Description |Example

|https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/Body.html[@Body]
|https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/MessageBody.html[@MessageBody]
| Allows explicitly indicating the body of the message to sent
|`@Body Product product`
|`@MessageBody Product product`

|https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/Header.html[@Header]
|https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/MessageHeader.html[@MessageHeader]
| Allows specifying a parameter that should be sent as a header
|`@Header("X-My-Header") String myHeader`
|`@MessageHeader("X-My-Header") String myHeader`

|ann:configuration.kafka.annotation.KafkaKey[]
| Allows specifying the parameter that is the Kafka key
Expand All @@ -146,4 +146,4 @@ The following table summarizes the annotations and their purpose, with an exampl

|===

For example, you can use the https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/Header.html[@Header] annotation to bind a parameter value to a header in the `ProducerRecord`.
For example, you can use the https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/MessageHeader.html[@MessageHeader] annotation to bind a parameter value to a header in the `ProducerRecord`.
10 changes: 5 additions & 5 deletions src/main/docs/guide/kafkaListener/kafkaListenerMethods.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ The following table summarizes the annotations and their purpose, with an exampl
|===
|Annotation |Description |Example

|https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/Body.html[@Body]
|https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/MessageBody.html[@MessageBody]
| Allows explicitly indicating the body of the message
|`@Body Product product`
|`@MessageBody Product product`

|https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/Header.html[@Header]
|https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/MessageHeader.html[@MessageHeader]
| Allows binding a parameter to a message header
|`@Header("X-My-Header") String myHeader`
|`@MessageHeader("X-My-Header") String myHeader`

|ann:configuration.kafka.annotation.KafkaKey[]
| Allows binding a parameter to the message key
Expand All @@ -53,7 +53,7 @@ The following table summarizes the annotations and their purpose, with an exampl

|===

For example, you can use the https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/Header.html[@Header] annotation to bind a parameter value from a header contained within a `ConsumerRecord`.
For example, you can use the https://docs.micronaut.io/latest/api/io/micronaut/messaging/annotation/MessageHeader.html[@MessageHeader] annotation to bind a parameter value from a header contained within a `ConsumerRecord`.


== Topics, Partitions and Offsets
Expand Down

0 comments on commit 93c571b

Please sign in to comment.