位置: 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)

  • 专利年费滞纳金计入什么科目
  • 政府补助是属于什么财务活动
  • 股份公司要实缴
  • 免税店含增值税吗
  • 基金会计核算的核算主体是
  • 受托代销商品和受托代销商品款是什么科目
  • 存货周转率 高
  • 生产企业有哪些费用
  • 城建税如何做会计分录
  • 出售无形资产属于让渡资产使用权吗
  • 商贸企业可以使用月末一次加权平均
  • 可以通过哪些渠道获得就业信息
  • 房开企业增值税确认收入时间
  • 汇算清缴后需要退税如何操作?
  • 人力资源服务差额
  • 租用办公室协议书
  • 退休人员返聘工资怎么发放
  • bios术语
  • 穿越火线改名卡买完了怎么用
  • 电脑经常重新启动是什么原因
  • 没有了睡眠功能
  • PHP:oci_bind_array_by_name()的用法_Oracle函数
  • 企业所得税汇算交税分录
  • php的正则表达式
  • 捐赠支出如何做账
  • 在建工程账务处理管理制度
  • php图像
  • Vue:element-ui中表格过长内容隐藏显示
  • 未摊销完的房租转哪个科目
  • php数组实现
  • 所得税减免要做账吗
  • 应收账款管理费会计分录
  • 暂估收入如何做账
  • 信用卡收款怎么查询
  • 库存商品用于研发要进项税额转出吗
  • 请问如何在
  • 暂存款账务处理
  • 差旅费包括内容
  • 环保工程会计处理
  • 固定资产未登记入账
  • 企业汇总纳税的原则
  • 分红是怎么分的?
  • 分配现金股利如何做会计分录
  • 长期的待摊费用包括哪些
  • 残保金中上年在职职工工资总额
  • 车辆etc设备
  • 银行收到客户货款会计分录
  • 开业前的装修费怎么做账
  • 忘交残保金了怎么补交
  • 明细分类账的填写
  • sql的all和any
  • 关于月亮的诗句
  • mac电脑双系统
  • 英文版西游记
  • ubuntu18.04lts
  • windows自带的应用程序
  • ubuntu20设置ip
  • window8系统安装步骤
  • 拒绝远程操作
  • xp系统能用谷歌吗
  • 在linux中使用什么命令可以执行shell脚本
  • win8系统没有wifi
  • windows8咋关机
  • windows8截图保存在哪里
  • Unity AssetBundle爬坑手记
  • oracle创建emp表
  • jQuery插件能输出到控制台
  • html用div来写表格
  • unity3d怎么查看
  • javascript html5 canvas实现可拖动省份的中国地图
  • nodejs定义数组
  • linux中gzip的用法
  • 使用JQuery选择HTML遍历函数的方法
  • JavaScript+html5 canvas绘制渐变区域完整实例
  • jQuery插件能输出到控制台
  • 第三届一带一国际高峰论坛
  • 江苏省增值税专用发票怎么开
  • 土地增值税按什么价格
  • 开票信息电子版怎么做
  • 重庆税务总局重庆电子税务局
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设