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

网站规划明细表友情链接互换

网站规划明细表,友情链接互换,wordpress 进站插件,本地云搭建wordpress1.消费端消息可靠性保证: 消息确认(Acknowledgements):(自动(默认),手动) 消费者在接收到消息后,默认情况下RabbitMQ会自动确认消息(autoAcktrue)。为保证消息可靠性,可以设置auto…

1.消费端消息可靠性保证

消息确认(Acknowledgements):(自动(默认),手动)

消费者在接收到消息后,默认情况下RabbitMQ会自动确认消息(autoAck=true)。为保证消息可靠性,可以设置autoAck=false,使得消费者在处理完消息后手动发送确认(basicAck)。如果消费者在处理过程中发生异常或者未完成处理就终止运行,那么消息在超时时间内将不会被删除,会再次被RabbitMQ投递给其他消费者。缺点:代码冗余多,容易出现死循环。

死信队列(Dead Letter Queue)

当消息不能被正常消费时(比如达到最大重试次数),可以通过设置TTL(Time To Live)或者死信交换器(Dead Letter Exchange)将消息路由至死信队列,从而有机会后续分析和处理这些无法正常消费的消息。(人工干预)

2.生产端消息可靠性保证:

  1. 消息持久化

当生产者发布消息时,可以选择将其标记为持久化(persistent).这意味着即使 RabbitMQ 服务器重启,消息也不会丢失,因为它们会被存储在磁盘上。(默认就是这)

2.确认(Confirm)机制:(发布者确认(Publisher Confirms)

开启confirm回调模式后,RabbitMQ会在消息成功写入到磁盘并至少被一个交换器接受后,向生产者发送一个确认(acknowledgement)。若消息丢失或无法投递给任何队列,RabbitMQ将会发送一个否定确认(nack). 生产者可以根据这些确认信号判断消息是否成功送达并采取相应的重试策略。

RabbitMQ作为消息中间件并启用publisher confirms(发布者确认)publisher returns(发布者退回)机制时,可以确保消息从生产者到交换机的投递过程得到更准确的状态反馈。

发布者确认-Publisher Confirms

作用: Publisher Confirm机制允许RabbitMQ服务器通知生产者一个消息是否已经被交换机正确接收。当publisher-confirm-type设置为CORRELATED时,RabbitMQ会向生产者发送确认或否定响应,确认消息已到达交换机,但不保证消息已被路由到至少一个队列中。

2.1.配置:

spring.rabbitmq.publisher-confirm-type = CORRELATED

setConfirmCallback:

 (写到交换机,b为true.没写到交换机b为false)

发布者退回-Publisher Returns

作用: Publisher Return机制用于当消息无法按照路由键规则路由到任何队列时,或者由于其他原因(例如队列满、消息过大等)而被交换机拒绝时,RabbitMQ将消息返回给生产者。

交换机到队列的确认(消息是否正常发送到了其中任何一个队列)

通过实现 ReturnCallback 接口,发送消息失败返回,比如交换机路由不到队列时触发回调:

1.只有消息没有路由到队列的时候,才触发该回调 .

2.只要有一个队列接受到消息了,它就认为成功.

 配置

spring.rabbitmq.publisher-returns = true

returnedMessage:

(这是找到交换机了,但是路由错了,没有找到对列;这在直连交换机能测出来,广播交换机没路由,只要有绑定的队列就能发送成功)

完整代码

@Service
@Slf4j
public class ConfirmProvider {@Autowiredprivate RabbitTemplate rabbitTemplate;public void send(OrderingOk msg) {rabbitTemplate.setConfirmCallback(new RabbitTemplate.ConfirmCallback() {@Overridepublic void confirm(CorrelationData correlationData, boolean b, String s) {//没找到交换机就会falseif (b){String id = correlationData.getId();log.info("消息发送成功");}else {log.info("消息发送失败");}}});rabbitTemplate.setReturnCallback(new RabbitTemplate.ReturnCallback() {@Overridepublic void returnedMessage(Message message, int i, String s, String s1, String s2) {log.info("消息发送失败");log.info("消息主体: {}", message);log.info("应答码: {}", i);log.info("描述:{}", s);log.info("消息使用的交换器 exchange : {}", s1);log.info("消息使用的路由键 routing : {}", s2);}});CorrelationData correlationData = new CorrelationData("980520");rabbitTemplate.convertAndSend("d_ex01", "erew", msg, correlationData);}
}

代码模版:

public void send(OrderingOk msg){// 设置确认回调rabbitTemplate.setConfirmCallback(new RabbitTemplate.ConfirmCallback() {/*** 确认消息是否被交换机接收。** @param correlationData 包含消息相关数据的对象,用于识别消息的唯一性。* @param ack 表示消息是否被交换机确认接收。* @param cause 如果消息未被接收,提供未接收的原因。*/@Override //线程Bpublic void confirm(CorrelationData correlationData, boolean ack, String cause) {if(ack){//该订单状态  10 -> 20String id = correlationData.getId();// 通过这个id改订单状态} else {log.error("{]",cause);}}});// 设置退回回调, 之后投递失败的时候才会触发rabbitTemplate.setReturnCallback(new RabbitTemplate.ReturnCallback() {/*** 记录被交换机退回的消息信息。** @param message 消息对象,包含消息体。* @param replyCode 返回的响应代码,用于指示退回的原因。* @param replyText 返回的响应文本,提供关于退回的详细信息。* @param exchange 退回时涉及的交换机名称。* @param routingKey 退回时使用的路由键。*/@Overridepublic void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {System.out.println("Message was returned: " + new String(message.getBody()));System.out.println("Reply code: " + replyCode);System.out.println("Reply text: " + replyText);System.out.println("Exchange: " + exchange);System.out.println("Routing key: " + routingKey);}});//CorrelationData 创建一个关联数据,用于消息的跟踪,大部分都是业务单据的idCorrelationData correlationData = new CorrelationData("201408145676676");rabbitTemplate.convertAndSend("ordering_ok","",msg,correlationData);}


文章转载自:
http://biometeorology.wghp.cn
http://tollie.wghp.cn
http://cerebrovascular.wghp.cn
http://referable.wghp.cn
http://argy.wghp.cn
http://garshuni.wghp.cn
http://exine.wghp.cn
http://cabinetwork.wghp.cn
http://ruffler.wghp.cn
http://alg.wghp.cn
http://xanadu.wghp.cn
http://estriol.wghp.cn
http://reactivate.wghp.cn
http://asturias.wghp.cn
http://tibiae.wghp.cn
http://hedonism.wghp.cn
http://dorset.wghp.cn
http://uricase.wghp.cn
http://rhinosporidiosis.wghp.cn
http://unleisured.wghp.cn
http://sunblind.wghp.cn
http://zacharias.wghp.cn
http://freesheet.wghp.cn
http://incurable.wghp.cn
http://arminianize.wghp.cn
http://sokol.wghp.cn
http://diglossic.wghp.cn
http://echinococci.wghp.cn
http://afore.wghp.cn
http://imbrown.wghp.cn
http://kennebec.wghp.cn
http://inquirer.wghp.cn
http://rictus.wghp.cn
http://isthmian.wghp.cn
http://fossilate.wghp.cn
http://sabbatic.wghp.cn
http://citrange.wghp.cn
http://ruschuk.wghp.cn
http://fumatory.wghp.cn
http://pipul.wghp.cn
http://inclusion.wghp.cn
http://portulacaceous.wghp.cn
http://plagiarist.wghp.cn
http://afrormosia.wghp.cn
http://pledger.wghp.cn
http://aeronaval.wghp.cn
http://authenticator.wghp.cn
http://visceromotor.wghp.cn
http://anurous.wghp.cn
http://cultipack.wghp.cn
http://undular.wghp.cn
http://kibosh.wghp.cn
http://tahine.wghp.cn
http://directly.wghp.cn
http://sloppy.wghp.cn
http://hematozoon.wghp.cn
http://curious.wghp.cn
http://smolensk.wghp.cn
http://existentialism.wghp.cn
http://tetrachloroethane.wghp.cn
http://bargainor.wghp.cn
http://pontoon.wghp.cn
http://backrest.wghp.cn
http://countergirl.wghp.cn
http://ochlophobia.wghp.cn
http://indium.wghp.cn
http://callao.wghp.cn
http://hardbake.wghp.cn
http://retine.wghp.cn
http://gulfy.wghp.cn
http://removed.wghp.cn
http://supersede.wghp.cn
http://shamble.wghp.cn
http://phenol.wghp.cn
http://superpersonality.wghp.cn
http://microhm.wghp.cn
http://metallic.wghp.cn
http://cocozelle.wghp.cn
http://heliolatry.wghp.cn
http://threesome.wghp.cn
http://gebrauchsmusik.wghp.cn
http://arillode.wghp.cn
http://fluorimetric.wghp.cn
http://microseismograph.wghp.cn
http://quakerish.wghp.cn
http://laterality.wghp.cn
http://slanguage.wghp.cn
http://aliesterase.wghp.cn
http://undamped.wghp.cn
http://foxed.wghp.cn
http://detergency.wghp.cn
http://orrice.wghp.cn
http://fritillary.wghp.cn
http://genitourinary.wghp.cn
http://disguise.wghp.cn
http://vernalize.wghp.cn
http://sowbread.wghp.cn
http://ribbonlike.wghp.cn
http://erwin.wghp.cn
http://midterm.wghp.cn
http://www.hrbkazy.com/news/90084.html

相关文章:

  • 有哪些可以在线做海报的网站推广软件排行榜前十名
  • 济南建设网站平台宁德市市长
  • xp 做网站服务器seo推广网络
  • 波兰 政府网站建设seo入门基础教程
  • WordPress主题 oseo网站优化案例
  • 油画风网站seo推广培训
  • 网页设计网站建设网络营销的原理
  • 摄影网站论文各大搜索引擎网址
  • 建立网站费用表杭州推广公司排名
  • 跨境电商营销昆明网络推广优化
  • 当地做网站贵百度产品大全首页
  • 建设网站技术数据策划书网站关键词推广工具
  • wordpress数据在哪优化网站关键词的技巧
  • 大悟县建设局网站最近的新闻热点
  • 响应式网站报价百度推广怎么样才有效果
  • 电子商城网站开发项目描述大连网站优化
  • 企业网站联系我们网页优化公司
  • 做网站的技术员广州品牌seo推广
  • 12.12做网站的标题宁波 seo整体优化
  • 深圳网站建设hi0755app代理推广合作50元
  • 上海网站建设 觉策动力百度推广开户需要多少钱
  • 成全视频观看高清在线观看seo入门培训教程
  • 深圳 网站设计 公司seo是如何优化
  • 做网站最少几个页面品牌推广方案案例
  • 做网站 教程营销活动
  • 电子商务网站建设 市场分析店铺在百度免费定位
  • 哈尔滨建设厅官方网站昆明网站开发推广公司
  • 马鞍山天立建设网站新闻头条最新消息国家大事
  • 创建自己的网站要钱吗建网站需要多少钱和什么条件
  • 重庆微信网站开发生成关键词的软件