当前位置: 首页 > news >正文

免费搭建平台网站做网站 客户一直要求改

免费搭建平台网站,做网站 客户一直要求改,wordpress汉化包,电脑版网站制作公司Direct消息模型 * 路由模型#xff1a; * 一个交换机可以绑定多个队列 * 生产者给交换机发送消息时#xff0c;需要指定消息的路由键 * 消费者绑定队列到交换机时#xff0c;需要指定所需要消费的信息的路由键 * 交换机会根据消息的路由键将消息转发到对应的队…Direct消息模型 * 路由模型 * 一个交换机可以绑定多个队列 * 生产者给交换机发送消息时需要指定消息的路由键 * 消费者绑定队列到交换机时需要指定所需要消费的信息的路由键 * 交换机会根据消息的路由键将消息转发到对应的队列* 缺点 * 当消息很多的时候需要指定的路由键也会很多究极复杂。生产者 package com.example.demo02.mq.direct;import com.example.demo02.mq.util.ConnectionUtils; import com.rabbitmq.client.BuiltinExchangeType; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection;import java.io.IOException;/*** author Allen* 4/11/2024 9:30 AM* version 1.0* description: 路由模型发送者** 路由模型* 一个交换机可以绑定多个队列* 生产者给交换机发送消息时需要指定消息的路由键* 消费者绑定队列到交换机时需要指定所需要消费的信息的路由键* 交换机会根据消息的路由键将消息转发到对应的队列* 缺点* 当消息很多的时候需要指定的路由键也会很多究极复杂。*/ public class DirectSender {public static void main(String[] args) throws Exception {// 1创建连接Connection connection ConnectionUtils.getConnection();// 2创建通道Channel channel connection.createChannel();// 3声明交换机 参数1交换机名称 参数2交换机类型 参数3是否持久化channel.exchangeDeclare(direct.exchange, BuiltinExchangeType.DIRECT, false);// 6发送消息String msg1 {To DirectReceiver1: orderId:1001};String msg2 {To DirectReceiver2: orderId:1002};// 参数1交换机 参数2路由键(与消费者相匹配) 参数3其他参数 参数4消息内容channel.basicPublish(direct.exchange,order.save,null,msg1.getBytes());channel.basicPublish(direct.exchange,order.update,null,msg2.getBytes());// 7关闭通道channel.close();// 8关闭连接connection.close();} }消费者1 package com.example.demo02.mq.direct;import com.example.demo02.mq.util.ConnectionUtils; import com.rabbitmq.client.*;import java.io.IOException;/*** author Allen* 4/11/2024 9:44 AM* version 1.0* description: 路由模型接收者1*/ public class DirectReceiver1 {public static void main(String[] args) throws Exception {Connection connection ConnectionUtils.getConnection();Channel channel connection.createChannel();channel.exchangeDeclare(direct.exchange, BuiltinExchangeType.DIRECT, false);channel.queueDeclare(direct.queue1, false, false, false, null);channel.queueBind(direct.queue1,direct.exchange,order.save);Consumer consumer new DefaultConsumer(channel){Overridepublic void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {System.out.println(DirectReceiver1接收到的新增订单消息是 new String(body));channel.basicAck(envelope.getDeliveryTag(),false);}};channel.basicConsume(direct.queue1,false,consumer);} }消费者2 package com.example.demo02.mq.direct;import com.example.demo02.mq.util.ConnectionUtils; import com.rabbitmq.client.*;import java.io.IOException;/*** author Allen* 4/11/2024 9:44 AM* version 1.0* description: 路由模型接收者2*/ public class DirectReceiver2 {public static void main(String[] args) throws Exception {Connection connection ConnectionUtils.getConnection();Channel channel connection.createChannel();channel.exchangeDeclare(direct.exchange, BuiltinExchangeType.DIRECT, false);channel.queueDeclare(direct.queue2, false, false, false, null);channel.queueBind(direct.queue2,direct.exchange,order.update);Consumer consumer new DefaultConsumer(channel){Overridepublic void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {System.out.println(DirectReceiver2接收到的修改订单消息 new String(body));channel.basicAck(envelope.getDeliveryTag(),false);}};channel.basicConsume(direct.queue2,false,consumer);} }结果
http://www.pierceye.com/news/981374/

相关文章:

  • 美工需要的网站阿里云wordpress托管
  • 医疗行业网站建设怎样在网上建立平台
  • 潍坊网站建设网超之梦做的网站后台修改栏目描述
  • 广西建设厅官网证件查询网站优化对企业有什么好处
  • 哪个网站做外贸的多济南建设信息网官网
  • 制作网站能挣钱企业宣传片策划公司
  • 临沂网站建设模板wordpress添加导航页面
  • 有关wordpress教学的网站商标注册号
  • 常用搜索网站浙江立鹏建设有限公司网站
  • 天津做网站优化的公司番禺商城网站建设
  • 网站建设大熊猫点搜营销型网站头部布局的元素
  • wordpress 网站死机淄博专业网站建设价格
  • 网站建设 招标书慈溪机械加工网
  • dede网站怎么做404页面做网站的市场有那么大吗
  • 自己做下载类网站家在深圳网页版
  • 建设银行网站个人客户传奇新服网
  • 河东手机网站建设工作服厂家联系方式
  • 站长工具seo综合查询搭建流程
  • 各省住房和城乡建设厅网站怎样租用个人网站空间
  • 深圳市南山区住房和建设局网站官网桂林两江四湖象山景区讲解导游词
  • 环保网站设计是什么柴沟堡做网站公司
  • 用php和mysql做网站wordpress怎么创建自己的博客
  • 网站建设制作设计珠海百度收录排名
  • 有没有做家具特卖的网站360建筑
  • 网站建设技术架构学校网站建设源代码
  • 无为教育网站网站平面设计培训
  • 广东省建筑网站信誉好的低价网站建设
  • 高端网站建设 杭州做效果图网站
  • 进贤县住房和城乡建设局网站短网址生成网站源码
  • 手机网站用二级目录做的弊端四川建设人员数据网站