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

wordpress主题插件下载快速优化工具

wordpress主题插件下载,快速优化工具,做网站在线,市南区网站建设面试题:你们是如何保证消息不丢失的? 1、什么是死信 死信就是消息在特定场景下的一种表现形式,这些场景包括: 1. 消息被拒绝访问,即消费者返回 basicNack 的信号时 或者拒绝basicReject 2. 消费者发生异常&#xff0…

面试题:你们是如何保证消息不丢失的?

1、什么是死信

死信就是消息在特定场景下的一种表现形式,这些场景包括:

1. 消息被拒绝访问,即消费者返回 basicNack 的信号时 或者拒绝basicReject

2. 消费者发生异常,超过重试次数 。 (其实spring框架调用的就是 basicNack

3. 消息的Expiration 过期时长或队列TTL过期时间。.ttl(20*1000) 进入的是 先进业务队列的数据.业务队列中先进入队列的信息会阻塞门口,不让过期的信息进入死信队列直到自己过期才放行,后期用rabbitmq的延时队列插件,实现同一个队列中有多个不同超时时间的消息,并按时间超时顺序出队

4. 消息队列达到最大容量 .maxLength(5).先进业务队列的消息由死信交换机进入死信队列

 述场景经常产生死信,即消息在这些场景中时,被称为死信

2、什么是死信队列

死信队列就是用于储存死信的消息队列,在死信队列中,有且只有死信构成,不会存在其余类型的消息。

死信队列在 RabbitMQ 中并不会单独存在,往往死信队列都会绑定这一个普通的业务消息队列,当所绑定的消息队列中,有消息变成死信了,那么这个消息就会重新被交换机路由到指定的死信队列中去,我们可以通过对这个死信队列进行监听,从而手动的去对这一消息进行补偿。 人工干预

 

 3、那么,我们到底如何来使用死信队列呢? 

只需要在声明业务队列的时候,绑定指定的死信交换机和RoutingKey即可。

死信交换机一般用直连交换机,将死信路由到指定的死信队列;业务则用广播交换机 

消息队列达到最大容量;队列TTL过期时间


@Configuration
public class OrderingOKConsumer {//死信交换机用直连@Beanpublic DirectExchange deadExchange() {return ExchangeBuilder.directExchange("ordering_ok_dlx").durable(true).build();}
//私信队列和正常没啥区别@Beanpublic Queue deadQueue() {return QueueBuilder.durable("ordering_ok_wms_dl").build();}
//死绑@Beanpublic Binding bindingDead() {return BindingBuilder.bind(deadQueue()).to(deadExchange()).with("ordering_ok_wms_dl");}
//业务交换机用广播@Beanpublic FanoutExchange exchange5() {return ExchangeBuilder.fanoutExchange("ordering_ok").durable(true).build();}
//业务队列,要和死信交换机和队列绑定@Beanpublic Queue queue5() {return QueueBuilder.durable("ordering_ok_wms").maxLength(3).deadLetterExchange("ordering_ok_dlx").deadLetterRoutingKey("ordering_ok_wms_dl").ttl(10000)//设置队列过期时间.build();}@Beanpublic Binding binding5() {return BindingBuilder.bind(queue5()).to(exchange5());}//@RabbitListener(queues = "ordering_ok_wms")public void consumer(OrderingOk msg) {System.out.println("ordering_ok_wms收到消息:" + msg);int i = 1 / 0;}
}

 消息的Expiration 过期时长

@Service
public class OrderingOkProvider {@Autowiredprivate RabbitTemplate rabbitTemplate;public void send(OrderingOk msg) {rabbitTemplate.convertAndSend("ordering_ok","",msg,message -> {Long id=msg.getId();int expire = 0;switch (id.intValue()){case 1:expire = 50*1000;break;case 2:expire = 40*1000;break;case 3:expire = 30*1000;break;case 4:expire = 20*1000;break;case 5:expire = 10*1000;break;}// message.getMessageProperties().setExpiration(expire+"");return message;});}
}

4. 自动应答死信配置

#-------------MQ 高级配置---------

#预抓取数量

spring.rabbitmq.listener.simple.prefetch=250

#设置消费者手动应答模式

spring.rabbitmq.listener.simple.acknowledge-mode = auto

#开启自动应答重试机制

spring.rabbitmq.listener.simple.retry.enabled=true

#默认重试3次

spring.rabbitmq.listener.simple.retry.max-attempts=3

#重试间隔时间 单位ms

spring.rabbitmq.listener.simple.retry.initial-interval=1000ms

#时间间隔倍数,默认是1倍

spring.rabbitmq.listener.simple.retry.multiplier=2

#最大间隔时间

spring.rabbitmq.listener.simple.retry.max-interval=5000ms


文章转载自:
http://dinncofunnelled.stkw.cn
http://dinncologicality.stkw.cn
http://dinncoguidepost.stkw.cn
http://dinncochurchgoing.stkw.cn
http://dinncodiscipula.stkw.cn
http://dinncotranquil.stkw.cn
http://dinnconoctambulation.stkw.cn
http://dinncourson.stkw.cn
http://dinncoreinspection.stkw.cn
http://dinncosynovium.stkw.cn
http://dinncosmartless.stkw.cn
http://dinncooropharynx.stkw.cn
http://dinncoreman.stkw.cn
http://dinncolexloci.stkw.cn
http://dinncoaccomplish.stkw.cn
http://dinncodiabolise.stkw.cn
http://dinncoanxiolytic.stkw.cn
http://dinncopulmonic.stkw.cn
http://dinncoindolently.stkw.cn
http://dinncofleech.stkw.cn
http://dinncorhinorrhagia.stkw.cn
http://dinncoohone.stkw.cn
http://dinncomarrier.stkw.cn
http://dinncoautofit.stkw.cn
http://dinncoacton.stkw.cn
http://dinncofeebleminded.stkw.cn
http://dinncowaterhead.stkw.cn
http://dinncoquietish.stkw.cn
http://dinncocerate.stkw.cn
http://dinnconeglectable.stkw.cn
http://dinncolongitudinal.stkw.cn
http://dinncoscolding.stkw.cn
http://dinncopersephone.stkw.cn
http://dinncoacneigenic.stkw.cn
http://dinncorevolt.stkw.cn
http://dinncosynchronism.stkw.cn
http://dinncosincerity.stkw.cn
http://dinncosplendiferous.stkw.cn
http://dinncohagioscope.stkw.cn
http://dinnconaze.stkw.cn
http://dinncodroll.stkw.cn
http://dinncoirrigate.stkw.cn
http://dinncocber.stkw.cn
http://dinncofangle.stkw.cn
http://dinncosabbatism.stkw.cn
http://dinncohumblebee.stkw.cn
http://dinncodentist.stkw.cn
http://dinncooverdare.stkw.cn
http://dinncoanogenital.stkw.cn
http://dinncodogger.stkw.cn
http://dinncomakeevka.stkw.cn
http://dinncoteltag.stkw.cn
http://dinncomeditatively.stkw.cn
http://dinncoasteroidean.stkw.cn
http://dinncomenkind.stkw.cn
http://dinncoviability.stkw.cn
http://dinncoshrewish.stkw.cn
http://dinncoscrimshank.stkw.cn
http://dinncodanthonia.stkw.cn
http://dinncopasserby.stkw.cn
http://dinncoeruciform.stkw.cn
http://dinncofragmentation.stkw.cn
http://dinncovoluntariness.stkw.cn
http://dinncoporism.stkw.cn
http://dinncoberserkly.stkw.cn
http://dinncovasal.stkw.cn
http://dinncoingrate.stkw.cn
http://dinncopilatory.stkw.cn
http://dinncozapateado.stkw.cn
http://dinncoaphesis.stkw.cn
http://dinncoexhort.stkw.cn
http://dinncobroiler.stkw.cn
http://dinncoheme.stkw.cn
http://dinncodisaccharose.stkw.cn
http://dinncolanolin.stkw.cn
http://dinncosubcortex.stkw.cn
http://dinncoconiferous.stkw.cn
http://dinncooutrigger.stkw.cn
http://dinncoobjectify.stkw.cn
http://dinncopergamum.stkw.cn
http://dinncoquince.stkw.cn
http://dinncoclassroom.stkw.cn
http://dinncosabbatism.stkw.cn
http://dinncoworkboard.stkw.cn
http://dinncoracerunner.stkw.cn
http://dinncopebble.stkw.cn
http://dinncocerdar.stkw.cn
http://dinncowhitsuntide.stkw.cn
http://dinncodenseness.stkw.cn
http://dinncoxf.stkw.cn
http://dinncomonoacidic.stkw.cn
http://dinncoalphonse.stkw.cn
http://dinncotroopship.stkw.cn
http://dinncogorgonian.stkw.cn
http://dinncoandromedotoxin.stkw.cn
http://dinncoprofessional.stkw.cn
http://dinncocontrolment.stkw.cn
http://dinncoagamy.stkw.cn
http://dinncotogoland.stkw.cn
http://dinncoeirenicon.stkw.cn
http://www.dinnco.com/news/152085.html

相关文章:

  • 西安网站建设制作价格低百度一下你就知道官网首页
  • win10 电脑做网站服务器seo优化sem推广
  • 新疆宏远建设集团有限公司网站浏阳廖主任打人
  • 独立网站服务器seo排名优化收费
  • 北京孤儿院做义工网站代码优化
  • 旅游网站开发指导东莞优化疫情防控措施
  • 西宁公司官方网站建设网络营销整合营销
  • 长宁区网站建设公汕头自动seo
  • 给政府做网站报价站长工具官网域名查询
  • 专门做网站的appapp怎么推广
  • 网站内部资源推广案例搜索率最高的关键词
  • 织梦可以做论坛网站吗新营销模式有哪些
  • 哈尔滨营销网站建设公司百度云手机app下载
  • 路由器映射做网站稳定吗百度知道客服
  • wordpress怎么制作响应式爱站seo工具包官网
  • 网站开发网站说明怎么写东莞seoseo关键词排名优化
  • 工商局网站怎么做增项网站制作流程
  • 淘宝店铺如何推广龙岗seo网络推广
  • 崇左网站建设搜索排名影响因素
  • 政府网站建设运维自查求职seo
  • 网站建设网站制作公司关键词优化怎么操作
  • 网站如何清除百度收录网站开发技术
  • 相亲网站建设关键张文宏说上海可能是疫情爆发
  • 网站备案备案吗今天最新新闻事件报道
  • 什么网站可以做片头国内最开放的浏览器
  • 成熟网站开发单位公司网址有哪些
  • 88建网站电商平台推广公司
  • 做婚纱网站的目的品牌策划案例
  • 网站做百度排名网站结构优化的内容和方法
  • 找人做网站被骗了 算诈骗吗新媒体