當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
RabbitMQ整合SpringBoot(web)
生活随笔
收集整理的這篇文章主要介紹了
RabbitMQ整合SpringBoot(web)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
一、index.html
<!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><title>Title</title> </head> <body> <a href="/testFanout">testFanout</a> <a href="/testHello">testHello</a> <a href="/testRoute">testRoute</a> <a href="/testTopic">testTopic</a> <a href="/testWork">testWork</a> </body> </html>二、controller
@RestController public class MyController {//注入rabbitTemplate@Autowiredprivate RabbitTemplate rabbitTemplate;//topic 動態(tài)路由 訂閱模式@GetMapping("/testTopic")@ResponseBodypublic String testTopic() {rabbitTemplate.convertAndSend("topics", "product.save.add", "produce.save.add 路由消息");return "testTopic";}//route 路由模式@GetMapping("/testRoute")@ResponseBodypublic String testRoute() {rabbitTemplate.convertAndSend("directs", "error", "發(fā)送info的key的路由信息");return "testRoute";}//fanout 廣播@GetMapping("/testFanout")@ResponseBodypublic String testFanout() {rabbitTemplate.convertAndSend("logs", "", "Fanout的模型發(fā)送的消息");return "testFanout";}//work@GetMapping("/testWork")@ResponseBodypublic String testWork() {for (int i = 0; i < 10; i++) {rabbitTemplate.convertAndSend("work", "work模型" + i);}return "testWork";}//hello world@GetMapping("/testHello")@ResponseBodypublic String testHello() {rabbitTemplate.convertAndSend("hello", "hello world");return "testHello";} }三、回調(diào)層
四、yml
spring:application:name: rabbitmq-springbootrabbitmq:host:x.x.x.xport: 5672username: emspassword: 123virtual-host: /ems總結(jié)
以上是生活随笔為你收集整理的RabbitMQ整合SpringBoot(web)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2021年中国医药营销数字化研究报告
- 下一篇: Docker安装zookeeper 单节