sidebar_position |
---|
30 |
import CodeBlock from '@theme/CodeBlock'; import CodeConfigurationProperties from '!!raw-loader!./snippets/_configuration_properties.properties';
Add the following to the spring application.properties
file:
{CodeConfigurationProperties}
It's recommended to structure the project such that all consumers and producers (classes containing listener/producer methods) are in the same package - it's not mandatory, and if they're scattered across multiple packages, just provide the highest in hierarchy package that contains all classes.
The base-package
will be scanned for classes containing @Component
annotated classes (that includes @Service
annotated classes) for methods annotated with @JmsListener
, @KafkaListener
, MessageMapping
, @RabbitListener
, @SqsListener
, @AsyncListener
, @AsyncPublisher
, etc.
@Configuration
classes are scanned for @Bean
containing the previously mentioned annotations as well.
The Info
object provides metadata about the API (see Info Object.
All provided fields will be present in the generated document, but not all will be displayed in the UI.
The Server
object provides metadata to help the reader understand the protocol, version, login details and more (see AsyncAPI Server Object).
Any name (kafka-server
in the example) can be chosen.
An AsyncAPI document can contain more than one server, but it's not common.
As with the Info
object, all provided fields will be present in the generated document, but not all will be displayed in the UI.
The Identifier
value represents a unique universal identifier of the application. See Identifier.
A string representing the default content type to use when encoding/decoding a message's payload. See Default Content Type
The default is application/json
and it has an effect on the payload example
generation. Also supported: text/xml
, application/yaml
.
The AsyncAPI specification allows the definition of additional data fields to extend the specification at certain points (see Specification Extensions ).
Extension Fields may be added to Info
, Contact
, License
and Server
objects both via application.properties
.
Every custom extension field must begin with x-
, for example x-internal-id
(see sample configurations above).
The following table contains additional properties that can be specified in the application.properties
file:
Property Name | Default Value | Description |
---|---|---|
springwolf.enabled |
true |
Allows to enable/disable Springwolf at one central place. |
springwolf.init-mode |
fail_fast |
Springwolf initializes during start up with fail_fast or in the background after the application has started. |
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. |
springwolf.endpoint.actuator.enabled |
false |
Publish the AsyncAPI document as part of Spring Boot’s actuator feature. |
springwolf.use-fqn |
true |
Use fully qualified names for the schema classes. Required for publishing with springwolf-ui |
springwolf.studio-compatibility |
true |
Activate tweaks to allow viewing & editing in AsyncAPI studio |
springwolf.payload.extractable-classes.. |
N/A | Extract additional payload types. See message payloads for more details. |
springwolf.scanner.async-listener.enabled |
true |
Enable scanner to find methods annotated with @AsyncListener . |
springwolf.scanner.async-publisher.enabled |
true |
Enable scanner to find methods annotated with @AsyncPublisher . |
AMQP | ||
springwolf.plugin.amqp.publishing.enabled |
false |
Allow (anyone) to produce AMQP messages from the UI. Note that this has security implications |
springwolf.plugin.amqp.scanner.rabbit-listener.enabled |
true |
Enable scanner to find methods annotated with @RabbitListener . |
JMS | ||
springwolf.plugin.jms.publishing.enabled |
false |
Allow (anyone) to produce JMS messages from the UI. Note that this has security implications |
springwolf.plugin.jms.scanner.jms-listener.enabled |
true |
Enable scanner to find methods annotated with @JmsListener . |
Kafka | ||
springwolf.plugin.kafka.publishing.enabled |
false |
Allow (anyone) to produce Kafka messages from the UI. Note that this has security implications |
springwolf.plugin.kafka.publishing.producer |
null |
Configure the Kafka producer used to publish messages from the UI. Uses identical parameters as spring.kafka.producer . SpringwolfKafkaProducer demonstrates multiple producer configuration to publish to Avro and Protobuf. |
springwolf.plugin.kafka.scanner.kafka-listener.enabled |
true |
Enable scanner to find methods annotated with @KafkaListener . |
SNS | ||
springwolf.plugin.sns.publishing.enabled |
false |
Allow (anyone) to produce SNS messages from the UI. Note that this has security implications |
SQS | ||
springwolf.plugin.sqs.publishing.enabled |
false |
Allow (anyone) to produce SQS messages from the UI. Note that this has security implications |
springwolf.plugin.sqs.scanner.sqs-listener.enabled |
true |
Enable scanner to find methods annotated with @SqsListener . |
STOMP (WebSocket) | ||
springwolf.plugin.stomp.scanner.stomp-message-mapping.enabled |
true |
Enable scanner to find methods annotated with @MessageMapping . |
springwolf.plugin.stomp.scanner.stomp-send-to.enabled |
true |
Enable scanner to find methods annotated with @SendTo . |
springwolf.plugin.stomp.scanner.stomp-send-to-user.enabled |
true |
Enable scanner to find methods annotated with @SendToUser . |
Springwolf supports exposing the AsyncAPI document as part of Spring Boot’s actuator endpoint.
The AsyncAPI document will then be moved underneath actuators base path, that's /actuator/springwolf
.
To enable it, add the spring-boot-actuator
dependency first.
Second, enable the actuator endpoint in the application.properties
file:
# Move Springwolf endpoint to actuator
springwolf.endpoint.actuator.enabled=true
# Expose Springwolf endpoint in spring
management.endpoints.web.exposure.include=springwolf
If the actuator management port is configured differently than the application port or the actuator base path is changed, then the exposed AsyncAPI document will follow accordingly.
:::note Enabling actuator support for Springwolf will break the Springwolf UI.