当前位置:网站首页>Rambbmitmq Push Party
Rambbmitmq Push Party
2022-06-22 05:16:00 【a good idea】
package com.demo.common;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitConfig {
@Bean
Queue testQueue(){
System.out.println("testQueue--------------------");
// Queue name
return new Queue("testQueue");
}
/**
* Switch
* @return
*/
@Bean
DirectExchange testExchange(){
return new DirectExchange("testExchange");
}
/**
* Bind the switch to the queue
*/
@Bean
Binding testBinding(){
return BindingBuilder
.bind(testQueue())
.to(testExchange())
.with("testKey");
}
}
package com.demo.controller;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SendMsgController {
@Autowired
private RabbitTemplate rabbitTempate;
// This interface is used to send messages
@GetMapping("/send")
public String sendMsg(String msg) {
rabbitTempate.convertAndSend("testExchange","testKey",msg);
return "OK";
}
}
server.port=8081
spring.application.name=mq
spring.rabbitmq.host=
# The following are the default values , It can be written without modification
spring.rabbitmq.username=
spring.rabbitmq.password=
spring.rabbitmq.port=5672
package com.demo;
import javafx.application.Application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages={"com.demo"})
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>边栏推荐
- 这是一个图片
- Flink deployment mode (II) - three deployment modes of yarn
- Tupu software 2D and 2.5D case collection | smart Park, data center, SMT production line
- What are the high availability designs of yarn?
- Graph calculation on nlive:nepal's graph calculation practice
- 9 practical shell scripts, recommended collection!
- 8. Gateway request logging
- lua笔记
- Literacy of C language concept knowledge (supplemented and updated from time to time)
- Contents of 2022 tea master (intermediate) examination and tea master (intermediate) examination
猜你喜欢

Using Matplotlib to realize GUI interaction effect

Idea创建方法时,使用注解提示方法参数(param)、返回值(return)、方法作用(Description)

Accelerate the promotion of industrial Internet, and map out a new blueprint for development

畢業回饋!Apache Doris 社區所有貢獻者來領禮品啦!
Solve the shortage of developers. Maybe it can help you

Squoosh - 谷歌出品的免费开源图片压缩工具,图片大小减少90%!支持 API 开发调用

Remote Dictionary Server(Redis)——基于 KV 结构的作为 Cache 使用的 NoSQL 数据库管理系统

Geographic location type of redis

2022 a special equipment related management (elevator) examination data and a special equipment related management (elevator) analysis

Non recursive printing Fibonacci sequence
随机推荐
2022 a special equipment related management (elevator) examination data and a special equipment related management (elevator) analysis
Create a new local content and upload it to the code cloud branch
9. Gateway cross domain processing
flink部署模式总结
Start with the strategy of small market value factor, and take you into quantitative investment (with the strategy of 77.83% annualized return)
TIDB-升级版本
C语言字符串的一些使用注意事项
mysql day01课堂笔记
TIDB-performance overview面板
How to display loading animation when requesting data
数据的备份与恢复
Graduation feedback! All contributors of Apache Doris community come to receive gifts!
Topic selection system of college graduation design based on SSM
Kubernetes——使用minikube搭建环境
Kubernetes——裸机搭建集群环境
Flink deployment mode (I) - standalone and Application
Remote dictionary server (redis) - a kV based NoSQL database management system used as a cache
IQueryable和IEnumerable的区别
1108. Defanging an IP Address
numpy庫常用知識整理