You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/documenting-consumers.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,9 @@
2
2
sidebar_position: 5
3
3
---
4
4
5
-
# Manually Documenting Consumers
5
+
# Documenting Consumers
6
6
7
-
Sometimes projects are configured in a way that makes Springwolf unable to automatically locate consumers, producers are defined imperatively (They don't have the `@KafkaListener` or `@RabbitListener` annotations on the consuming methods).
7
+
Sometimes projects are configured in a way that makes Springwolf unable to automatically locate consumers(They don't have the `@KafkaListener`, `@RabbitListener`, `@AsyncSubscriber` annotations on the consuming methods).
8
8
9
9
Because there is still immense value in documenting the consumers, Springwolf provides a way to explicitly add them to the generated document, by declaring them in the `AsyncApiDocket` using the `ConsumerData` object.
Copy file name to clipboardExpand all lines: docs/documenting-producers.md
+94-21Lines changed: 94 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,79 @@ sidebar_position: 5
6
6
7
7
Unlike consumers which are defined declaratively with an annotation, producers are defined imperatively, and there is no implementation uniform enough so that metadata can be picked up automatically.
8
8
9
-
Because producers are also an important part of Async APIs, Springwolf provides a way to explicitly add them to the generated document, by declaring them in the `AsyncApiDocket` using the `ProducerData` object.
9
+
Because producers are also an important part of Async APIs, Springwolf provides a way to explicitly add them to the generated document.
10
10
11
-
## `ProducerData`
11
+
To document them, either:
12
+
- add the `@AsyncPublisher` annotation or
13
+
- declare the `ProducerData` object as part of the `AsyncApiDocket`
14
+
15
+
## Option 1: `@AsyncPublisher`
16
+
17
+
The `@AsyncPublisher` annotation is added to the method of the publisher and extracts the payload from its arguments.
18
+
Additional fields can be documented.
19
+
20
+
The protocol binding is configured via `@AmqpAsyncOperationBinding` or `@KafkaAsyncOperationBinding`, which has to be on the same method.
21
+
22
+
Below is an example to demonstrate the annotation:
23
+
```java
24
+
@AsyncPublisher(operation=@AsyncOperation(
25
+
channelName="example-producer-topic",
26
+
description="Optional. Customer uploaded an example payload",
The channel name (or topic name in case of Kafka) - this is the name that will be used to publish messages to by the UI.
47
+
48
+
### Description
49
+
50
+
Optional. The description allows for human-friendly text to verbosely explain the _message_, like specific domain, what the topic is used for and which data it contains.
51
+
52
+
### Payload Type
53
+
54
+
The class object of the payload that will be published to this channel.
55
+
If not specified, it is extracted from the method arguments.
56
+
57
+
### Header
58
+
59
+
Optional. The headers describing the metadata of the payload.
60
+
61
+
### `@AmqpAsyncOperationBinding`
62
+
63
+
Associate this operation with amqp, see [operation-binding] for details.
Associate this operation with kafka, see [operation-binding] for details.
72
+
73
+
```java
74
+
@KafkaAsyncOperationBinding(
75
+
bindingVersion="1",
76
+
clientId="foo-clientId",
77
+
groupId="#{'foo-groupId'}"
78
+
)
79
+
```
80
+
81
+
## Option 2: `ProducerData`
12
82
13
83
:::tip
14
84
Use specific ProducerData types `AmqpProducerData` & `KafkaProducerData` for protocol specific attributes
@@ -49,7 +119,7 @@ Optional. The description allows for human-friendly text to verbosely explain th
49
119
50
120
### Binding
51
121
52
-
This property is used to discriminate the producer's protocol and provide protocol-specific properties (see [Operation Binding Object](https://www.asyncapi.com/docs/specifications/v2.0.0#operationBindingsObject)).
122
+
This property is used to discriminate the producer's protocol and provide protocol-specific properties (see [operation-binding])).
53
123
54
124
### Payload Type
55
125
@@ -62,7 +132,7 @@ By default, `AsyncHeaders.NOT_DOCUMENTED` is used to indicate that no explicit h
62
132
Use `AsyncHeaders` to add your custom headers, use `AsyncHeaders.NOT_USED` if you do not use headers and `AsyncHeadersForCloudEventsBuilder` if your events follow the CloudEvent specification.
63
133
64
134
65
-
## `AmqpProducerData`
135
+
###`AmqpProducerData`
66
136
67
137
The above Kafka `ProducerData` equivalent in `AmqpProducerData`:
68
138
```java
@@ -75,6 +145,21 @@ The above Kafka `ProducerData` equivalent in `AmqpProducerData`:
75
145
.build();
76
146
```
77
147
148
+
149
+
150
+
### `KafkaProducerData`
151
+
152
+
The above Kafka `ProducerData` simplifies to the following `KafkaProducerData`:
.description("Optional. Customer uploaded an example payload")
157
+
.payloadType(ExamplePayloadDto.class)
158
+
.headers(AsyncHeaders.NOT_USED)
159
+
.build();
160
+
```
161
+
162
+
## AMQP Parameters
78
163
### Queue Name (Channel Name)
79
164
80
165
The queue name that will be used to publish messages to by the UI.
@@ -95,22 +180,7 @@ The routing key used when publishing a message.
95
180
96
181
The class object of the payload that will be published to this channel.
97
182
98
-
### Example
99
-
100
-
See a full example [here](https://github.com/springwolf/springwolf-core/blob/master/springwolf-examples/springwolf-amqp-example/src/main/java/io/github/stavshamir/springwolf/example/configuration/AsyncApiConfiguration.java).
101
-
102
-
103
-
## `KafkaProducerData`
104
-
105
-
The above Kafka `ProducerData` simplifies to the following `KafkaProducerData`:
.description("Optional. Customer uploaded an example payload")
110
-
.payloadType(ExamplePayloadDto.class)
111
-
.headers(AsyncHeaders.NOT_USED)
112
-
.build();
113
-
```
183
+
## Kafka Parameters
114
184
115
185
### Topic Name (Channel Name)
116
186
@@ -132,4 +202,7 @@ The Springwolf Kafka plugin comes with a special `AsyncHeadersForSpringKafkaBuil
132
202
133
203
### Example
134
204
135
-
See a full example [here](https://github.com/springwolf/springwolf-core/blob/master/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/configuration/AsyncApiConfiguration.java).
0 commit comments