当前位置:   article > 正文

RabbitMQ spring boot整合MabbitMQ(完整演练)_springboot整合imb的mq

springboot整合imb的mq

简单案例

其案例之前要确定你安装了RabbitMQ 并且启动了RiabbitMQ 

启动lunix 并打开 

 

一般我们会设置 Rabbit是自动启动的,但害怕失效.所以再重启下:

systemctl start rabbitmq-server

我们再做几个简单案例,深度了解rabbitMQ

 新建springboot 或maven工程

pox.xml样要

pom.xml的设置

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>2.3.2.RELEASE</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>cn.tedu</groupId>
  12. <artifactId>rabbitmq-springboot</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>rabbitmq-springboot</name>
  15. <description>Demo project for Spring Boot</description>
  16. <properties>
  17. <java.version>1.8</java.version>
  18. </properties>
  19. <dependencies>
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter</artifactId>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-test</artifactId>
  27. <scope>test</scope>
  28. </dependency>
  29. <dependency>
  30. <groupId>org.springframework.boot</groupId>
  31. <artifactId>spring-boot-starter-amqp</artifactId>
  32. </dependency>
  33. </dependencies>
  34. <build>
  35. <plugins>
  36. <plugin>
  37. <groupId>org.springframework.boot</groupId>
  38. <artifactId>spring-boot-maven-plugin</artifactId>
  39. </plugin>
  40. </plugins>
  41. </build>
  42. </project>

新建消费方consumer 提供,:producer测试方Main1

consumer(简单模式)111111111111--------------------------------------------------------------------------------------------------------------------------------------------------

  1. package cn.tedu.rabbitmqspringboot.m1;
  2. import org.springframework.amqp.rabbit.annotation.Queue;
  3. import org.springframework.amqp.rabbit.annotation.RabbitHandler;
  4. import or
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/617056
推荐阅读
相关标签
  

闽ICP备14008679号