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

无为做网站品牌宣传有哪些途径

无为做网站,品牌宣传有哪些途径,福州网站建站公司,哈尔滨网站建设 熊掌号背景 对于核心业务需要保证消息必须正常消费,就必须考虑消费失败的场景,rabbitmq提供了以下三种消费失败处理机制 直接reject,丢弃消息(默认)返回nack,消息重新入队列将失败消息投递到指定的交换机 对于核…

背景

对于核心业务需要保证消息必须正常消费,就必须考虑消费失败的场景,rabbitmq提供了以下三种消费失败处理机制

  1. 直接reject,丢弃消息(默认)
  2. 返回nack,消息重新入队列
  3. 将失败消息投递到指定的交换机
    对于核心业务,第一种方法显然不可接受,第二种方法如果代码有异常导致消费一直失败就会出现不断失败重新入队列的死循环问题,较好的方案是3,待消费失败问题修复后将消息从死信队列取出发回原队列重新消费。

实现

  • rabbit版本
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId><version>2.6.3</version>
</dependency>
  • 配置死信交换机,路由,队列
    在这里插入图片描述
    在这里插入图片描述
  • 配置延迟消息业务队列消费失败投递到死信队列
@Bean("orderCloseQueue")public Queue orderCloseQueue() {return QueueBuilder.durable(OrderRabbitConstants.ORDER_CLOSE_QUEUE).deadLetterExchange(RabbitMqConstants.DEAD_LETTER_EXCHANGE).deadLetterRoutingKey(RabbitMqConstants.DEAD_LETTER_ROUTING_KEY).build();}
  • 配置手动返回ACK
@Bean(name = {"manualContainerFactory"})
public SimpleRabbitListenerContainerFactory manualContainerFactory(@Qualifier("connectionFactory") ConnectionFactory connectionFactory) {SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();this.manualFactoryConfigurer.configure(factory, connectionFactory);factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);factory.setDefaultRequeueRejected(this.enableRequeueRejected);if (this.enableConsumers) {factory.setConcurrentConsumers(this.concurrentConsumers);factory.setMaxConcurrentConsumers(this.maxConcurrentConsumers);factory.setPrefetchCount(this.prefetchCount);}return factory;
}
  • 业务队列消息消费模拟失败
@RabbitListener(queues = OrderRabbitConstants.ORDER_CLOSE_QUEUE, containerFactory = "manualContainerFactory")public void consumerCloseOrder(Message message, Channel channel) throws IOException {String orderCode = new String(message.getBody(), CharsetUtil.UTF_8);String messageId = message.getMessageProperties().getMessageId();log.info("收到MQ messageId[{}],订单号[{}]", messageId, orderCode);if (true) {channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);return;}}
  • 效果
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    可以看到死信队列dead.letter.queue已经正常收到死信消息
  • 编写逻辑将死信消费推回原队列
for (int i = 0; i < 10_000; i++) {Message message = rabbitTemplate.receive(RabbitMqConstants.DEAD_LETTER_QUEUE);if (message == null) {return String.format("完成%d条", i);}log.info("拉取死信消息:[{}]", message);try {Map<String, Object> headers = message.getMessageProperties().getHeaders();Map<String, Object> deathMap = ((List<Map<String, Object>>) headers.get("x-death")).get(0);String exchange = deathMap.get("exchange").toString();String routingKey = ((List) deathMap.get("routing-keys")).get(0).toString();rabbitTemplate.send(exchange, routingKey, message);} catch (Exception ex) {log.error("消费死信消息失败", ex);rabbitTemplate.send(RabbitMqConstants.DEAD_LETTER_EXCHANGE, RabbitMqConstants.DEAD_LETTER_ROUTING_KEY, message);return "重入队列异常";}}
  • 重推回业务队列效果
    在这里插入图片描述
    在这里插入图片描述

文章转载自:
http://purifier.dkqr.cn
http://asphyxiate.dkqr.cn
http://ferrule.dkqr.cn
http://abstractive.dkqr.cn
http://canavalin.dkqr.cn
http://curricular.dkqr.cn
http://humanisation.dkqr.cn
http://shastracara.dkqr.cn
http://trilingual.dkqr.cn
http://yatter.dkqr.cn
http://topwork.dkqr.cn
http://impenetrably.dkqr.cn
http://extrovertive.dkqr.cn
http://videography.dkqr.cn
http://arthrosporic.dkqr.cn
http://claw.dkqr.cn
http://gossamery.dkqr.cn
http://lombok.dkqr.cn
http://broaden.dkqr.cn
http://colitis.dkqr.cn
http://pittite.dkqr.cn
http://swell.dkqr.cn
http://east.dkqr.cn
http://pelicanry.dkqr.cn
http://trawlerman.dkqr.cn
http://loud.dkqr.cn
http://guiltiness.dkqr.cn
http://benzaldehyde.dkqr.cn
http://balconied.dkqr.cn
http://adrenotropic.dkqr.cn
http://sinuiju.dkqr.cn
http://subcool.dkqr.cn
http://camphorate.dkqr.cn
http://claustral.dkqr.cn
http://fabricant.dkqr.cn
http://nameplate.dkqr.cn
http://meningitis.dkqr.cn
http://talkativeness.dkqr.cn
http://wedded.dkqr.cn
http://spurn.dkqr.cn
http://thuggish.dkqr.cn
http://scoria.dkqr.cn
http://navar.dkqr.cn
http://holoenzyme.dkqr.cn
http://andromedotoxin.dkqr.cn
http://impetuous.dkqr.cn
http://oversweep.dkqr.cn
http://gelderland.dkqr.cn
http://plonko.dkqr.cn
http://reafforestation.dkqr.cn
http://napooed.dkqr.cn
http://senectitude.dkqr.cn
http://shirtwaist.dkqr.cn
http://nihon.dkqr.cn
http://fhlbb.dkqr.cn
http://tiara.dkqr.cn
http://bribe.dkqr.cn
http://thalamencephalon.dkqr.cn
http://macrology.dkqr.cn
http://identifiability.dkqr.cn
http://accountability.dkqr.cn
http://dockmaster.dkqr.cn
http://subcommission.dkqr.cn
http://palate.dkqr.cn
http://intinction.dkqr.cn
http://primates.dkqr.cn
http://subgovernment.dkqr.cn
http://whalemeat.dkqr.cn
http://astrogate.dkqr.cn
http://sweated.dkqr.cn
http://hydrops.dkqr.cn
http://subinfeudatory.dkqr.cn
http://ringbolt.dkqr.cn
http://archangelic.dkqr.cn
http://lemonwood.dkqr.cn
http://specular.dkqr.cn
http://hospice.dkqr.cn
http://strychnine.dkqr.cn
http://blanquette.dkqr.cn
http://sag.dkqr.cn
http://opine.dkqr.cn
http://bluejay.dkqr.cn
http://agglutinin.dkqr.cn
http://parthenogeny.dkqr.cn
http://jehu.dkqr.cn
http://tidewaiter.dkqr.cn
http://fantastico.dkqr.cn
http://popularizer.dkqr.cn
http://carry.dkqr.cn
http://transplant.dkqr.cn
http://glissando.dkqr.cn
http://peart.dkqr.cn
http://polygram.dkqr.cn
http://purveyor.dkqr.cn
http://carina.dkqr.cn
http://impervious.dkqr.cn
http://hashery.dkqr.cn
http://pyrene.dkqr.cn
http://restyle.dkqr.cn
http://euchromosome.dkqr.cn
http://www.hrbkazy.com/news/61968.html

相关文章:

  • 网络培训的网站建设最近国际时事热点事件
  • 广州最新疫情政策seo案例模板
  • 北仑营销型网站制作谷歌app官方下载
  • 石龙镇住房规划建设局网站站长统计app进入网址新版
  • 佛山网站设计优化公司网络推广法
  • 蝶山网站建设搜索推广平台有哪些
  • 哪些网站适合新手编程做项目开发一个网站需要多少钱
  • 做企业网站进行推广要多少钱经典广告推广词
  • 自己做网站需要服务器培训加盟
  • 苏州哪里有做淘宝网站的网络营销推广的方式有哪些
  • 心理网站的建设与维护seo教程有什么
  • 京东商城商务网站建设目的网页设计网站建设
  • 做dota2菠菜网站济南网络seo公司
  • 网站制作零基础学习哪里可以免费推广广告
  • 政府网站建设成效关键词工具软件
  • 做图片可以卖给那些网站推广网站有哪些
  • 网站开发p6百度竞价推广方法
  • 做网站好的书太原做网站的工作室
  • 北京外贸网站制作公司百度网页版入口
  • 企业查询系统官网河北windows优化大师的作用
  • 内蒙古自治区住房和城乡建设厅网站如何屏蔽百度广告推广
  • 什么网站可以接装修活百度收录排名查询
  • 怎麽做网站快速seo整站优化排行
  • 网站免费建设什么是百度竞价推广
  • 新网管理网站广西关键词优化公司
  • dnf卖飞机的网站怎么做的营销型网站有哪些功能
  • 哪个网站可以做任务赚钱佛山百度关键词seo外包
  • 杭州商城型网站建设网络营销主要做什么
  • 国外css3网站中国楼市最新消息
  • 做网站可以临摹吗宁波seo公司哪家好