Below is an example of how you can install and set up your service.
- Use the spring initalizer and create a Spring Boot application with
Spring Cloud Stream
dependencies https://start.spring.io - Add the digiwf-asyncapi-docs-starter dependency.
With Maven:
<dependency>
<groupId>io.muenchendigital.digiwf</groupId>
<artifactId>digiwf-asyncapi-docs-starter</artifactId>
<version>${digiwf.version}</version>
</dependency>
With Gradle:
implementation group: 'io.muenchendigital.digiwf', name: 'digiwf-asyncapi-docs-starter', version: '${digiwf.version}'
- Add the kafka binder (see Spring Cloud Stream).
Maven:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency>
Gradle:
implementation group: 'org.springframework.cloud', name: 'spring-cloud-stream-binder-kafka'
- Add properties for spring cloud stream consumers and producers to application.properties
spring.cloud.stream.default-binder=kafka
spring.cloud.stream.kafka.binder.brokers=localhost:9092
spring.cloud.function.definition=receiveMessage
spring.cloud.stream.bindings.receiveMessage-in-0.destination=kafka-demo-receive-message,kafka-demo-test1
spring.cloud.stream.bindings.receiveMessage-in-0.group=kafka-demo
- Setup the base package, version and title of docs for your application in the application.properties. For example
io.muenchendigital.digiwf.docs.enabled=true
io.muenchendigital.digiwf.docs.basePackage=io.muenchendigital.digiwf
io.muenchendigital.digiwf.docs.version=1.0.0
io.muenchendigital.digiwf.docs.title=kafka-example
-
Annotate your spring cloud functions with the
@DocumentAsyncAPI
annotation. For consumer and producer functions provide the payload to the annotation, e.g.@DocumentAsyncAPI(payload = YourClass.class)
. If you use a function router provide additionally the type header, e.g.@DocumentAsyncAPI(payload = YourClass.class, functionRouter = true, typeHeader = "yourTypeHeader")
. -
Check out the documentation at http://localhost:8080/springwolf/asyncapi-ui.html
For more information and code examples see documentation.md