首先要清楚rabbitmq基础知识
生产者:生产消息
消费者:消费监听指定队列的消息
配置类:将交换机队列绑定到一起
引入依赖:
<!-- mq -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- hutool -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<hutool.version>5.4.5</hutool.version>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
<lombok.version>1.18.16</lombok.version>
</dependency>
创建生产者:
@Component
@Slf4j
public class SendUserIntegralRabbitMqProducer {
@Resource
private RabbitTemplate rabbitTemplat