位置: IT常识 - 正文

RabbitMQ学习笔记(rabbitmq中文手册)

编辑:rootadmin
RabbitMQ 整合RabbitMQ /** * 使用RabbitMQ * 1、引入ampq场景,RabbitAutoConfiguration 就会自动生效 * 2、给容器中自动配置了 * RabbitTemplate、AmqpAdmin、CachingConnectionFactory、Rab ... RabbitMQ整合RabbitMQ/** * 使用RabbitMQ * 1、引入ampq场景,RabbitAutoConfiguration 就会自动生效 * 2、给容器中自动配置了 * RabbitTemplate、AmqpAdmin、CachingConnectionFactory、RabbitMessagingTemplate * 所有的属性都是在 * @EnableConfigurationProperties(RabbitProperties.class) * @ConfigurationProperties(prefix = "spring.rabbitmq") * public class RabbitProperties * 3、给配置文件中配置 spring.rabbitmq 信息 * 4、@EnableRabbit 开启功能 * 5、监听消息:使用 @RabbitListener,必须有 @EnableRabbit * @RabbitListener:类 + 方法上 * @RabbitHandler: 只能标在方法上 */<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId></dependency># rabbit 配置文件spring.rabbitmq.host=192.168.106.101spring.rabbitmq.port=5672spring.rabbitmq.virtual-host=/

推荐整理分享RabbitMQ学习笔记(rabbitmq中文手册),希望有所帮助,仅作参考,欢迎阅读内容。

RabbitMQ学习笔记(rabbitmq中文手册)

文章相关热门搜索词:rabbitmq入门案例,rabbitmq入门到精通,rabbit mq教程,rabbitmq入门,rabbitmq简书,rabbitmq入门,rabbit mq教程,rabbit mq教程,内容如对您有帮助,希望把文章链接给更多的朋友!

测试

package com.atguigu.gulimall.order;import com.atguigu.gulimall.order.entity.OrderReturnApplyEntity;import lombok.extern.slf4j.Slf4j;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.amqp.core.AmqpAdmin;import org.springframework.amqp.core.Binding;import org.springframework.amqp.core.DirectExchange;import org.springframework.amqp.core.Queue;import org.springframework.amqp.rabbit.core.RabbitTemplate;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.test.context.SpringBootTest;import org.springframework.test.context.junit4.SpringRunner;import java.util.Date;@Slf4j@RunWith(SpringRunner.class)@SpringBootTestpublic class GulimallOrderApplicationTests { @Autowired AmqpAdmin amqpAdmin; @Autowired RabbitTemplate rabbitTemplate; /** * 1、创建Exchange[hello.java.exchange]、Queue、Binding * - 使用 AmqpAdmin 进行创建 * * 2、如何收发消息 -> RabbitTemplate * 如果发送的消息是个对象,使用序列化机制,将对象写出去,对象实现 Serializable 接口 * 自定义序列化添加配置 * @Configuration * public class MyRabbitConfig { * @Bean * public MessageConverter messageConverter() { * return new Jackson2JsonMessageConverter(); * } * } */ @Test public void sendMessageTest() { String msg = "Hello World"; OrderReturnApplyEntity orderReturnApplyEntity = new OrderReturnApplyEntity(); orderReturnApplyEntity.setId(1L); orderReturnApplyEntity.setSkuName("华为"); orderReturnApplyEntity.setCreateTime(new Date()); rabbitTemplate.convertAndSend("hello.java.exchange", "hello.java", orderReturnApplyEntity); log.info("消息发送完成:{}", orderReturnApplyEntity); } @Test public void createExchange() { //amqpAdmin /** * DirectExchange * public DirectExchange(String name, boolean durable, boolean autoDelete, Map<String, Object> arguments) */ DirectExchange exchange = new DirectExchange("hello.java.exchange", true,false); amqpAdmin.declareExchange(exchange); log.info("Exchange[{}]创建成功", "hello.java.exchange"); } @Test public void createQueue() { /** * public Queue(String name, boolean durable, boolean exclusive, boolean autoDelete) */ Queue queue = new Queue("hello-java-queue", true, false,true); amqpAdmin.declareQueue(queue); log.info("Queue[{}]创建成功", "hello-java-queue"); } @Test public void createBinding() { /** * public Binding(String destination【目的地】, * DestinationType destinationType【目的地类型】, * String exchange【交换机】, * String routingKey【路由键】, * Map<String, Object> arguments)【参数】 * 将 exchange 指定交换机和 destination目的地进行绑定,使用routingKey作为指定路由键 */ Binding binding = new Binding("hello-java-queue", Binding.DestinationType.QUEUE,"hello.java.exchange","hello.java",null); amqpAdmin.declareBinding(binding); log.info("Binding == 创建成功"); }}

测试监听消息

/** * queues:
本文链接地址:https://www.jiuchutong.com/zhishi/309258.html 转载请保留说明!

上一篇:如何禁用WordPress的XML-RPC功能(如何禁用笔记本键盘触摸板)

下一篇:如何打开phpcms网站的数据库配置文件(开启php)

  • 全国增值税专用发票计算机稽核网络系统工程
  • 国家税务总局操作指引
  • 增值税小规模纳税人认定标准
  • 发票系统口令锁定
  • 个税退税需要交税吗
  • 农业企业增值税纳税实务实训心得
  • 事业单位存货发生盘亏或盘盈处理
  • 印花税计入哪个费用
  • 工资扣款做什么科目
  • 贴现利息可以抵扣吗
  • 老板垫付员工工资怎么写条子
  • 暂估费用时可以抵扣吗
  • 价税合计是什么会计科目
  • 吊车租赁增值税税率最新2022
  • 金税盘锁死去税务局流程
  • 接受政府无偿划拨固定资产税务处理
  • 购买方开具红字信息表
  • 房屋租赁费属于什么服务
  • 资产评估合同属于什么合同
  • 企业的银行利息收入要交企业所得税吗
  • 免税收入和不征税收入有哪些?怎么记忆
  • android 设置按钮颜色
  • 分期购车的会计分录
  • 广告费递延几年
  • 收到预付款怎么给客户写协议书
  • 增值税专用发票有几联?
  • 非常损失计入
  • wordpress 常用函数
  • windows没有搜索
  • 公司刚成立多久可以注销
  • sguard是什么
  • srv.exe病毒
  • 固定资产成本中的相关税费
  • 差额银行承兑汇票
  • yii2框架从入门到精通
  • PHP:imagecolortransparent()的用法_GD库图像处理函数
  • php年月日时间代码
  • 文化建设事业费优惠政策
  • phpadmin默认密码
  • 网络技术公司技能培训
  • 前端解决浏览器跨域问题
  • axios请求设置超时时间
  • vue docs
  • 原材料用于在建工程增值税如何处理
  • 增值税申报表各栏怎么填
  • 选择简易计税方法按照5%的征收率计税公式
  • 弃置费用摊销例题
  • 库存不足怎么处理
  • 房屋出租收入是其他业务收入吗
  • 发票种类8种分别是
  • mysql 重复记录查询
  • sql 列转行
  • 企业捐赠自产产品的所得税处理
  • 哪种发票可以报税
  • 开农贸市场拿补贴找哪个部门
  • 服务业预收账款什么时候确认收入
  • 电子承兑 背书
  • 进度款开票是开实收金额吗
  • 残疾人就业保障金会计分录怎么做
  • 研发支出的定义
  • 应收应付账款如何清理
  • 公司增资认缴
  • 将mater库中的系统存储过程批量生成*.sql文件 通用且非常实用
  • 组策略0x800704ec
  • 有备而来有备而去
  • 安装 apt
  • 基于centos6安装kvm服务
  • linux查看多线程
  • 用什么命令查看linux启动信息
  • js原生方法大全
  • python闭包的条件
  • 基于android的简单程序
  • python 批量查询
  • 广东省纳税信用等级
  • 盼之代售怎么下载
  • 如何在电子税务局变更财务负责人
  • 破产清算处置资产增值税
  • 长安cs752016款2.0手动
  • 什么是审计的重要特征,也是审计的精髓
  • 专家咨询费包括哪些内容
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设