Skip to content

gaojia0814/rocketmq-spring-boot-starter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rocketmq-spring-boot-starter

spring boot starter for RocketMQ

Maven Central

GitHub release

首先添加maven依赖:

<dependency>
    <groupId>com.maihaoche</groupId>
    <artifactId>spring-boot-starter-rocketmq</artifactId>
    <version>0.0.1</version>
</dependency>

添加配置:

rocketmq:
  name-server-address: 172.21.10.111:9876
  producer-group: local_pufang_producer

在springboot应用主入口添加@EnableMQConfiguration注解开启自动装配:

@SpringBootApplication
@EnableMQConfiguration
class CamaroDemoApplication {
}

创建发送方(详见wiki):

@MQProducer
class DemoProducer : AbstractMQProducer() {
}

创建消费方(详见wiki):

@MQConsumer(consumerGroup = "local_pufang_test_consumer", topic = "suclogger")
class DemoConsumer : AbstractMQPushConsumer<DemoMessage>() {
    override fun process(message:DemoMessage) : Boolean {
        return true
    }

}

发送消息:


// 注入发送者
@Autowired
lateinit var demoProducer:DemoProducer
    
...
    
// 发送
demoProducer.synSend("suclogger", "test message")
    

About

spring boot starter for RocketMQ

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%