nats-spring
Configuring a NATS client in Spring
This project provides support for using Spring Boot with NATS.
Quick Start
clone this project
git clone https://github.com/wanlinus/nats-spring.git
cd nats-spring
mvn clean install
<dependency>
<groupId>cn.wanlinus</groupId>
<artifactId>nats-spring</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
The Java SE 8 or higher is recommended to build the project.
Basic Usage
application.yml
spring:
nats:
urls:
- nats://127.0.0.1:4222
@EnableNats
@SpringBootApplication
public class NatsDemo2Application {
public static void main(String[] args) {
SpringApplication.run(NatsDemo2Application.class, args);
}
}
@Component
public class Foo{
@NatsSubscribe("haha")
public void message(Message message) {
System.out.println(message.getSubject() + " : " + new String(message.getData()));
}
}
Resources
For more information, please visit the Nats Spring website at: Reference Manual
License
Nats-Spring is released under the terms of the Apache 2.0 license.