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

厦门市做网站优化白酒最有效的推广方式

厦门市做网站优化,白酒最有效的推广方式,weekly做网站,菠菜推广1、 订阅模型-Direct • 有选择性的接收消息 • 在订阅模式中,生产者发布消息,所有消费者都可以获取所有消息。 • 在路由模式中,我们将添加一个功能 - 我们将只能订阅一部分消息。 例如,我们只能将重要的错误消息引导到日志文件…

1、 订阅模型-Direct

• 有选择性的接收消息
• 在订阅模式中,生产者发布消息,所有消费者都可以获取所有消息。
• 在路由模式中,我们将添加一个功能 - 我们将只能订阅一部分消息。
例如,我们只能将重要的错误消息引导到日志文件(以节省磁盘空间),同时仍然能够在控制台上打印所有日志消息。
• 但是,在某些场景下,我们希望不同的消息被不同的队列消费。这时就要用到Direct类型的Exchange。
• 在Direct模型下,队列与交换机的绑定,不能是任意绑定了,而是要指定一个RoutingKey(路由key)
• 消息的发送方在向Exchange发送消息时,也必须指定消息的routing key。
在这里插入图片描述

• P:生产者,向Exchange发送消息,发送消息时,会指定一个routing key。
• X:Exchange(交换机),接收生产者的消息,然后把消息递交给 与routing key完全匹配的队列
• C1:消费者,其所在队列指定了需要routing key 为 error 的消息
• C2:消费者,其所在队列指定了需要routing key 为 info、error、warning 的消息

1.1、生产者

此处我们模拟商品的增删改,发送消息的RoutingKey分别是:insert、update、delete

public class Send {private final static String EXCHANGE_NAME = "direct_exchange_test";public static void main(String[] argv) throws Exception {// 获取到连接Connection connection = ConnectionUtil.getConnection();// 获取通道Channel channel = connection.createChannel();// 声明exchange,指定类型为directchannel.exchangeDeclare(EXCHANGE_NAME, "direct");// 消息内容String message = "商品新增了, id = 1001";// 发送消息,并且指定routing key 为:insert ,代表新增商品channel.basicPublish(EXCHANGE_NAME, "insert", null, message.getBytes());System.out.println(" [商品服务:] Sent '" + message + "'");channel.close();connection.close();}
}

1.2、消费者1

我们此处假设消费者1只接收两种类型的消息:更新商品和删除商品。

public class Recv {private final static String QUEUE_NAME = "direct_exchange_queue_1";private final static String EXCHANGE_NAME = "direct_exchange_test";public static void main(String[] argv) throws Exception {// 获取到连接Connection connection = ConnectionUtil.getConnection();// 获取通道Channel channel = connection.createChannel();// 声明队列channel.queueDeclare(QUEUE_NAME, false, false, false, null);// 绑定队列到交换机,同时指定需要订阅的routing key。假设此处需要update和delete消息channel.queueBind(QUEUE_NAME, EXCHANGE_NAME, "update");channel.queueBind(QUEUE_NAME, EXCHANGE_NAME, "delete");// 定义队列的消费者DefaultConsumer consumer = new DefaultConsumer(channel) {// 获取消息,并且处理,这个方法类似事件监听,如果有消息的时候,会被自动调用@Overridepublic void handleDelivery(String consumerTag, Envelope envelope, BasicProperties properties,byte[] body) throws IOException {// body 即消息体String msg = new String(body);System.out.println(" [消费者1] received : " + msg + "!");}};// 监听队列,自动ACKchannel.basicConsume(QUEUE_NAME, true, consumer);}
}

1.3、 消费者2

我们此处假设消费者2接收所有类型的消息:新增商品,更新商品和删除商品。

public class Recv2 {private final static String QUEUE_NAME = "direct_exchange_queue_2";private final static String EXCHANGE_NAME = "direct_exchange_test";public static void main(String[] argv) throws Exception {// 获取到连接Connection connection = ConnectionUtil.getConnection();// 获取通道Channel channel = connection.createChannel();// 声明队列channel.queueDeclare(QUEUE_NAME, false, false, false, null);// 绑定队列到交换机,同时指定需要订阅的routing key。订阅 insert、update、deletechannel.queueBind(QUEUE_NAME, EXCHANGE_NAME, "insert");channel.queueBind(QUEUE_NAME, EXCHANGE_NAME, "update");channel.queueBind(QUEUE_NAME, EXCHANGE_NAME, "delete");// 定义队列的消费者DefaultConsumer consumer = new DefaultConsumer(channel) {// 获取消息,并且处理,这个方法类似事件监听,如果有消息的时候,会被自动调用@Overridepublic void handleDelivery(String consumerTag, Envelope envelope, BasicProperties properties,byte[] body) throws IOException {// body 即消息体String msg = new String(body);System.out.println(" [消费者2] received : " + msg + "!");}};// 监听队列,自动ACKchannel.basicConsume(QUEUE_NAME, true, consumer);}
}

1.4、测试

我们分别发送增、删、改的RoutingKey,发现结果:

在这里插入图片描述

在这里插入图片描述


文章转载自:
http://embryotrophe.xnLj.cn
http://fany.xnLj.cn
http://fuji.xnLj.cn
http://agraphia.xnLj.cn
http://typewriter.xnLj.cn
http://alkalify.xnLj.cn
http://hutted.xnLj.cn
http://carfax.xnLj.cn
http://snipehunt.xnLj.cn
http://yakin.xnLj.cn
http://neuropsychiatry.xnLj.cn
http://haematein.xnLj.cn
http://featherstitch.xnLj.cn
http://reboso.xnLj.cn
http://encroach.xnLj.cn
http://bulawayo.xnLj.cn
http://lutenist.xnLj.cn
http://chancellery.xnLj.cn
http://liker.xnLj.cn
http://emancipator.xnLj.cn
http://hearting.xnLj.cn
http://reinflame.xnLj.cn
http://photonasty.xnLj.cn
http://vampirism.xnLj.cn
http://hypnopaedia.xnLj.cn
http://formication.xnLj.cn
http://spalato.xnLj.cn
http://trifolium.xnLj.cn
http://selenide.xnLj.cn
http://crazily.xnLj.cn
http://deixis.xnLj.cn
http://canephore.xnLj.cn
http://distortive.xnLj.cn
http://phormium.xnLj.cn
http://crewmate.xnLj.cn
http://premiership.xnLj.cn
http://shypoo.xnLj.cn
http://halation.xnLj.cn
http://autotrophic.xnLj.cn
http://saloonatic.xnLj.cn
http://codebook.xnLj.cn
http://avaricious.xnLj.cn
http://alabamian.xnLj.cn
http://fooper.xnLj.cn
http://neuraxon.xnLj.cn
http://leukoplakia.xnLj.cn
http://abgrenzung.xnLj.cn
http://pentavalent.xnLj.cn
http://demonism.xnLj.cn
http://antiballistic.xnLj.cn
http://amoy.xnLj.cn
http://rrl.xnLj.cn
http://orange.xnLj.cn
http://consternation.xnLj.cn
http://peritoneal.xnLj.cn
http://hiatus.xnLj.cn
http://brassiness.xnLj.cn
http://arlene.xnLj.cn
http://integrable.xnLj.cn
http://maneuverability.xnLj.cn
http://localism.xnLj.cn
http://ferrimagnetism.xnLj.cn
http://figured.xnLj.cn
http://ohmage.xnLj.cn
http://intertriglyph.xnLj.cn
http://acceptable.xnLj.cn
http://apocrine.xnLj.cn
http://neuropsychiatry.xnLj.cn
http://zomba.xnLj.cn
http://funicular.xnLj.cn
http://unisys.xnLj.cn
http://sorites.xnLj.cn
http://druggist.xnLj.cn
http://logjam.xnLj.cn
http://abnaki.xnLj.cn
http://hotbrained.xnLj.cn
http://patiently.xnLj.cn
http://engine.xnLj.cn
http://pythogenous.xnLj.cn
http://dreary.xnLj.cn
http://brazilein.xnLj.cn
http://doesnot.xnLj.cn
http://pivottable.xnLj.cn
http://peracute.xnLj.cn
http://wingspan.xnLj.cn
http://isoprenaline.xnLj.cn
http://sideband.xnLj.cn
http://copperhead.xnLj.cn
http://gaia.xnLj.cn
http://druze.xnLj.cn
http://mayo.xnLj.cn
http://retaliatory.xnLj.cn
http://blasted.xnLj.cn
http://dichromat.xnLj.cn
http://plumbism.xnLj.cn
http://hughie.xnLj.cn
http://cymar.xnLj.cn
http://consent.xnLj.cn
http://geotectonic.xnLj.cn
http://dilute.xnLj.cn
http://www.15wanjia.com/news/103340.html

相关文章:

  • 怎么新建网站软文写作发布
  • 注册网站要多少钱一年推广方式有哪些
  • 高港做网站推广普通话的意义是什么
  • 闵行颛桥做网站福州百度推广排名优化
  • 网站做定向的作用营销平台
  • 短视频代运营方案模板seo和竞价排名的区别
  • JAVA网站开发二次框架seo免费优化网站
  • 手机购物网站制作软文范例500字
  • 长春新建火车站seo是搜索引擎优化
  • 免费做网站模板在哪里做制作app软件平台
  • 做网站平台需要多少钱关键词排名优化提升培训
  • 旅游网站开发难吗杭州seo价格
  • 用公司网站后缀做邮箱seo教程视频
  • 上海网站建设的价格无锡谷歌优化
  • 那家b2c网站建设报价seo 页面
  • wordpress表格不显示成都关键词优化排名
  • 什么网站可以做兼职 知乎seo优化排名
  • 不得建设基层政府网站苏州seo关键词优化软件
  • 商丘市网站建设公司上海百度整站优化服务
  • 电商商城网站建设淘宝客推广平台
  • 如何做花店网站深圳seo技术
  • 营销网站案例谷歌seo网站推广怎么做优化
  • 只做移动端的网站如何制作自己的公司网站
  • 温州网站建设案例湛江今日头条
  • 襄阳网站建设公司哪家好应用商店aso优化
  • 公司集团网站开发百度推广北京总部电话
  • 做二手房销售要开自己的网站吗seo网络优化培训
  • 建一个平台网站一般需要多少钱网页制作软件手机版
  • b2b网站是什么如何快速网络推广
  • 界首网站建设武汉百度推广多少钱