
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
@asyncapi/java-spring-template
Advanced tools
Use your AsyncAPI definition to generate java code to subscribe and publish messages
To have correctly generated code, your AsyncAPI file MUST define operationId for every operation.
In order for the generator to know what names to use for some parameters it's necessary to make use of AsyncAPI specification bindings.
channels:
event.lighting.measured:
publish:
bindings:
kafka:
groupId: my-group
message:
$ref: '#/components/messages/lightMeasured'
subscribe:
message:
$ref: '#/components/messages/lightMeasured'
Usage: ag [options] <asyncapi> @asyncapi/java-spring-template
Options:
-V, --version output the version number
-o, --output <outputDir> directory where to put the generated files (defaults to current directory)
-p, --param <name=value> additional param to pass to templates
-h, --help output usage information
| Name | Description | Required | Default |
|---|---|---|---|
| disableEqualsHashCode | Disable generation of equals and hashCode methods for model classes. | No | false |
| inverseOperations | Generate an application that will publish messages to publish operation of channels and read messages from subscribe operation of channels. Literally this flag will simply swap publish and subscribe operations in the channels. This flag will be useful when you want to generate a code of mock for your main application. Be aware, generation could be incomplete and manual changes will be required e.g. if bindings are defined only for case of main application. | No | false |
| javaPackage | The Java package of the generated classes. Alternatively you can set the specification extension info.x-java-package. If both extension and parameter are used, parameter has more priority. | No | com.asyncapi |
| springBoot2 | Generate template files for the Spring Boot version 2. For kafka protocol it will also force to use spring-kafka 2.9.9 | No | false |
| maven | Generate pom.xml Maven build file instead of Gradle build. | No | false |
| listenerPollTimeout | Only for Kafka. Timeout in ms to use when polling the consumer. | No | 3000 |
| listenerConcurrency | Only for Kafka. Number of threads to run in the listener containers. | No | 3 |
| addTypeInfoHeader | Only for Kafka. Add type information to message header. | No | true |
| connectionTimeout | Only for MQTT. This value, measured in seconds, defines the maximum time interval the client will wait for the network connection to the MQTT server to be established. The default timeout is 30 seconds. A value of 0 disables timeout processing meaning the client will wait until the network connection is made successfully or fails. | No | 30 |
| disconnectionTimeout | Only for MQTT. The completion timeout in milliseconds when disconnecting. The default disconnect completion timeout is 5000 milliseconds. | No | 5000 |
| completionTimeout | Only for MQTT. The completion timeout in milliseconds for operations. The default completion timeout is 30000 milliseconds. | No | 30000 |
| mqttClientId | Only for MQTT. Provides the client identifier for the MQTT server. This parameter overrides the value of the clientId if it's set in the AsyncAPI file.If both aren't provided, a default value is set. | No | |
| asyncapiFileDir | Path where original AsyncAPI file will be stored. | No | src/main/resources/api/ |
The shortest possible syntax:
ag asyncapi.yaml @asyncapi/java-spring-template
Specify where to put the result and define poll timeout:
ag -o ./src asyncapi.yaml -p listenerPollTimeout=5000 @asyncapi/java-spring-template
If you don't have the AsyncAPI Generator installed, you can install it like this:
npm install -g @asyncapi/generator
Clone the repository:
git clone https://github.com/asyncapi/java-spring-template
cd java-spring-template
Make sure template has all the dependencies:
npm install
Install AsyncAPI Generator:
npm install -g @asyncapi/generator
Run generation:
# for MQTT protocol test with below
ag tests/mocks/mqtt.yml ./ --output output
# for Kafka protocol test with below
ag tests/mocks/kafka.yml ./ --output output
Explore generated files in output directory
For local development, you need different variations of this command. First of all, you need to know about three important CLI flags:
--debug enables the debug mode.--watch-template enables a watcher of changes that you make in the template. It regenerates your template whenever it detects a change.--install enforces reinstallation of the template.Go to the root folder of the generated code and run this command (you need the JDK1.8):
./gradlew bootRun
Generated source contains RabbitMQ docker-compose. So you could use it to test amqp with:
docker-compose -f src/main/docker/rabbitmq.yml up -d
See the list of features that are still missing in the component:
amqp could be out of date. Please have a look to application.yaml and AmqpConfig.javaamqp are not providedparameters for topics are not supportedserver variables are not entirely supportedsecurity schemas are not supportedtraits are not supportedcontent typeIf you want to help us develop them, feel free to contribute.
Thanks goes to these wonderful people (emoji key):
Semen 📖 💻 | Francesco Nobilia 👀 | Amrut Prabhu 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Java Spring template for AsyncAPI generator.
The npm package @asyncapi/java-spring-template receives a total of 2,103 weekly downloads. As such, @asyncapi/java-spring-template popularity was classified as popular.
We found that @asyncapi/java-spring-template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.