Skip to content

Commit 043d51b

Browse files
authored
Update documenting-producers.md
Specify that @payload is needed when multiple parameter methods are annotated with @AsyncPublisher
1 parent 3903cc8 commit 043d51b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

docs/configuration/documenting-producers.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Additional fields can be documented.
1818

1919
On the same method, the protocol binding is defined. More details can be found in the [bindings](documenting-bindings.md) section.
2020

21-
Below is an example to demonstrate the annotation:
21+
### Single parameter
22+
Below is an example to demonstrate the annotation with a single parameter method:
2223

2324
```java
2425
@AsyncPublisher(operation = @AsyncOperation(
@@ -31,6 +32,23 @@ public void sendMessage(ExamplePayloadDto msg) {
3132
// process
3233
}
3334
```
35+
### Multiple parameters
36+
The `@Payload` annotation is necessary for methods with multiple parameters, indicating which parameter is the payload. If this annotation is missing when multiple parameters are present, the Publisher will not be documented.
37+
38+
The annotation is available by importing the `spring-messaging` library.
39+
40+
Here's an example:
41+
```java
42+
@AsyncPublisher(operation = @AsyncOperation(
43+
channelName = "example-producer-topic",
44+
description = "Customer uploaded an example payload", // Optional
45+
servers = {"kafka-server"} // Optional
46+
))
47+
@KafkaAsyncOperationBinding
48+
public void sendMessage(@Payload ExamplePayloadDto msg, String otherParam) {
49+
// process
50+
}
51+
```
3452

3553
:::note
3654
Springwolf only finds methods that are within the `base-package`.

0 commit comments

Comments
 (0)