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
|`springwolf.enabled`|`true`| Allows to disable springwolf at one central place.|
69
+
|`springwolf.enabled`|`true`| Allows to enable/disable springwolf at one central place. |
70
70
|`springwolf.paths.docs`|`/springwolf/docs`| The path of the AsyncAPI document in JSON format. *Note that at the moment the UI will work only with the default value.*|
71
71
|`springwolf.plugin.amqp.publishing.enabled`|`false`| Allow (anyone) to produce amqp messages from the UI. *Note that this has security implications*|
72
72
|`springwolf.plugin.kafka.publishing.enabled`|`false`| Allow (anyone) to produce kafka messages from the UI. *Note that this has security implications*|
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).
7
+
Springwolf comes with build-in support to auto-detect listeners of supported protocols.
8
8
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.
9
+
Sometimes projects are configured in a way that makes Springwolf unable to automatically locate consumers or the generated documentation is insufficient.
10
+
For these use-cases, Springwolf provides additional ways to explicitly add them to the generated document.
10
11
11
-
## `ConsumerData`
12
+
To document consumers, either:
13
+
- add the `@AsyncSubscriber` annotation or
14
+
- declare the `ConsumerData` object as part of the `AsyncApiDocket` or
15
+
- rely on the auto-detection of `@KafkaListener`, `@RabbitListener`
16
+
17
+
You are free to use all options together. Per channel and operation, first `ConsumerData` is used, then `@AsyncSubscriber` and last the auto-detected annotations.
18
+
19
+
## Option 1: `@AsyncSubscriber`
20
+
21
+
The `@AsyncSubscriber` annotation is added to the method of the listeners and extracts the payload from its arguments.
22
+
Additional fields can be documented.
23
+
24
+
The protocol operation binding is configured via `@AmqpAsyncOperationBinding` or `@KafkaAsyncOperationBinding`, which has to be on the same method.
25
+
26
+
Below is an example to demonstrate the annotation:
27
+
```java
28
+
@KafkaListener
29
+
@AsyncSubscriber(operation=@AsyncOperation(
30
+
channelName="example-consumer-topic",
31
+
description="Optional. Customer uploaded an example payload",
Springwolf only finds methods that are within the `base-package`.
51
+
:::
52
+
53
+
### Channel Name
54
+
55
+
The channel name (or topic name in case of Kafka) - this is the name that will be used to subscribe to messages to by the UI.
56
+
57
+
### Description
58
+
59
+
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.
60
+
61
+
### Payload Type
62
+
63
+
The class object of the payload that will be consumed from this channel.
64
+
If not specified, it is extracted from the method arguments.
65
+
66
+
### Header
67
+
68
+
Optional. The headers describing the metadata of the payload.
69
+
70
+
### `@AmqpAsyncOperationBinding`
71
+
72
+
Associate this operation with amqp, see [operation-binding] for details.
Associate this operation with kafka, see [operation-binding] for details.
81
+
82
+
```java
83
+
@KafkaAsyncOperationBinding(
84
+
bindingVersion="1",
85
+
clientId="foo-clientId",
86
+
groupId="#{'foo-groupId'}"
87
+
)
88
+
```
89
+
90
+
91
+
## Option 2: `ConsumerData`
12
92
13
93
:::tip
14
94
Use specific ConsumerData types `AmqpConsumerData` & `KafkaConsumerData` for protocol specific attributes
@@ -49,7 +129,7 @@ Optional. The description allows for human-friendly text to verbosely explain th
49
129
50
130
### Binding
51
131
52
-
This property is used to discriminate the consumer's protocol and provide protocol-specific properties (see [Operation Binding Object](https://www.asyncapi.com/docs/specifications/v2.0.0#operationBindingsObject)).
132
+
This property is used to discriminate the producer's protocol and provide protocol-specific properties (see [operation-binding])).
53
133
54
134
### Payload Type
55
135
@@ -62,7 +142,7 @@ By default, `AsyncHeaders.NOT_DOCUMENTED` is used to indicate that no explicit h
62
142
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
143
64
144
65
-
## `AmqpConsumerData`
145
+
###`AmqpConsumerData`
66
146
67
147
The above Kafka `ConsumerData` equivalent in `AmqpConsumerData`:
68
148
```java
@@ -75,9 +155,29 @@ The above Kafka `ConsumerData` equivalent in `AmqpConsumerData`:
75
155
.build();
76
156
```
77
157
158
+
### `KafkaConsumerData`
159
+
160
+
The above Kafka `ConsumerData` simplifies to the following `KafkaConsumerData`:
.description("Optional. Customer uploaded an example payload")
165
+
.payloadType(ExamplePayloadDto.class)
166
+
.headers(AsyncHeaders.NOT_USED)
167
+
.build();
168
+
```
169
+
170
+
171
+
## Option 3: `@KafkaListener`, `@RabbitListener`
172
+
The `@KafkaListener` and `@RabbitListener` annotations are detected automatically.
173
+
There is nothing more to do.
174
+
Use the other options if the provided documentation is insufficient.
175
+
176
+
177
+
## AMQP Parameters
78
178
### Queue Name (Channel Name)
79
179
80
-
The queue name that will be used to publish messages to by the UI.
180
+
The queue name that will be used to consume messages from.
81
181
82
182
### Description
83
183
@@ -95,26 +195,12 @@ The routing key used when publishing a message.
95
195
96
196
The class object of the payload that will be consumed from this channel.
97
197
98
-
### Example
99
198
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
-
## `KafkaConsumerData`
104
-
105
-
The above Kafka `ConsumerData` simplifies to the following `KafkaConsumerData`:
.description("Optional. Customer uploaded an example payload")
110
-
.payloadType(ExamplePayloadDto.class)
111
-
.headers(AsyncHeaders.NOT_USED)
112
-
.build();
113
-
```
199
+
## Kafka Parameters
114
200
115
201
### Topic Name (Channel Name)
116
202
117
-
The topic name that will be used to publish messages to by the UI.
203
+
The topic name that will be used to consume messages from.
118
204
119
205
### Description
120
206
@@ -130,7 +216,10 @@ The Kafka headers describing the metadata of the payload, more details in the ge
130
216
131
217
The Springwolf Kafka plugin comes with a special `AsyncHeadersForSpringKafkaBuilder` to document the `__TypeId__` header of the spring-kafka dependency.
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).
Copy file name to clipboardExpand all lines: docs/documenting-producers.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,16 +8,18 @@ Unlike consumers which are defined declaratively with an annotation, producers a
8
8
9
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
-
To document them, either:
11
+
To document producers, either:
12
12
- add the `@AsyncPublisher` annotation or
13
13
- declare the `ProducerData` object as part of the `AsyncApiDocket`
14
14
15
+
You are free to use all options together. Per channel and operation, first `ProducerData` is used, then `@AsyncPublisher`.
16
+
15
17
## Option 1: `@AsyncPublisher`
16
18
17
19
The `@AsyncPublisher` annotation is added to the method of the publisher and extracts the payload from its arguments.
18
20
Additional fields can be documented.
19
21
20
-
The protocol binding is configured via `@AmqpAsyncOperationBinding` or `@KafkaAsyncOperationBinding`, which has to be on the same method.
22
+
The protocol operation binding is configured via `@AmqpAsyncOperationBinding` or `@KafkaAsyncOperationBinding`, which has to be on the same method.
21
23
22
24
Below is an example to demonstrate the annotation:
23
25
```java
@@ -76,12 +78,11 @@ Associate this operation with kafka, see [operation-binding] for details.
76
78
77
79
```java
78
80
@KafkaAsyncOperationBinding(
79
-
bindingVersion="1",
80
-
clientId="foo-clientId",
81
-
groupId="#{'foo-groupId'}"
81
+
bindingVersion="1"
82
82
)
83
83
```
84
84
85
+
85
86
## Option 2: `ProducerData`
86
87
87
88
:::tip
@@ -149,8 +150,6 @@ The above Kafka `ProducerData` equivalent in `AmqpProducerData`:
149
150
.build();
150
151
```
151
152
152
-
153
-
154
153
### `KafkaProducerData`
155
154
156
155
The above Kafka `ProducerData` simplifies to the following `KafkaProducerData`:
@@ -163,6 +162,7 @@ The above Kafka `ProducerData` simplifies to the following `KafkaProducerData`:
163
162
.build();
164
163
```
165
164
165
+
166
166
## AMQP Parameters
167
167
### Queue Name (Channel Name)
168
168
@@ -184,6 +184,7 @@ The routing key used when publishing a message.
184
184
185
185
The class object of the payload that will be published to this channel.
186
186
187
+
187
188
## Kafka Parameters
188
189
189
190
### Topic Name (Channel Name)
@@ -204,9 +205,10 @@ The Kafka headers describing the metadata of the payload, more details in the ge
204
205
205
206
The Springwolf Kafka plugin comes with a special `AsyncHeadersForSpringKafkaBuilder` to document the `__TypeId__` header of the spring-kafka dependency.
0 commit comments