confirm

面试题(RabbitMQ)

孤街浪徒 提交于 2019-12-01 00:04:14
1、什么是RabbitMQ?为什么使用RabbitMQ? 答:RabbitMQ是一款开源的,Erlang编写的,基于AMQP协议的,消息中间件; 可以用它来:解耦、异步、削峰。 2、RabbitMQ有什么优缺点? 答:优点:解耦、异步、削峰; 缺点:降低了系统的稳定性:本来系统运行好好的,现在你非要加入个消息队列进去,那消息队列挂了,你的系统不是呵呵了。因此,系统可用性会降低; 增加了系统的复杂性:加入了消息队列,要多考虑很多方面的问题,比如:一致性问题、如何保证消息不被重复消费、如何保证消息可靠性传输等。因此,需要考虑的东西更多,复杂性增大。 3、如何保证RabbitMQ的高可用? 答:没有哪个项目会只用一搭建一台RabbitMQ服务器提供服务,风险太大; 4、如何保证RabbitMQ不被重复消费? 答:先说为什么会重复消费:正常情况下,消费者在消费消息的时候,消费完毕后,会发送一个确认消息给消息队列,消息队列就知道该消息被消费了,就会将该消息从消息队列中删除; 但是因为网络传输等等故障,确认信息没有传送到消息队列,导致消息队列不知道自己已经消费过该消息了,再次将消息分发给其他的消费者。 针对以上问题,一个解决思路是:保证消息的唯一性,就算是多次传输,不要让消息的多次消费带来影响;保证消息等幂性; 比如:在写入消息队列的数据做唯一标示,消费消息时,根据唯一标识判断是否消费过; 5

RabbitMQ入门学习

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 22:43:20
一、消息队列学习 MQ是一个互联网架构中常见的解耦利器。 什么时候不使用MQ? 上游实时关注执行结果 什么时候使用MQ? 1)数据驱动的任务依赖,多个任务需要轮流执行,轮流订阅上一个任务。 2)上游不关心多下游执行结果,上游执行完发送到MQ,多下游订阅MQ。 3)异步返回执行时间长 死信队列多了一个过期的机制,到期会自动去尝试消费,通过死信交换机做匹配,选择想要的消费失败的消息。 https://ke.qq.com/course/288116#term_id=100341172 入门视频 消息中间件是在消息传输过程中保存消息的容器。队列的主要目的是提供路由并保证消息的传递。 特点 : 1异步处理模式 2多个应用程序调用关系为松耦合关系 传递模型: 1、点多点模型PTP 每个消息只用一个消费者 发送者和接收者没有时间依赖 接受者确认消息接受和处理成功 2、发布-订阅模型Pub/Sub 一对多关系,通过订阅主题,发布者建立一个订阅,订阅者保持持续的活动状态以接收消息。 每个消息可以有多个订阅者 客户端只有订阅后才能接收到消息,有时间依赖。 持久订阅 订阅关系建立后,消息不会消失,不管订阅者是否都在线 非持久订阅 订阅者为了接受消息,必须一直在线 典型的应用案例 1、注册时发送邮件或发送短信 2、日志分析使用,多个服务产生的数据发送到中间件发送到分析服务。 3、消息复制

RabbitMQ实战(三)-高级特性

旧城冷巷雨未停 提交于 2019-11-30 21:16:06
0 相关源码 1 你将学到 如何保证消息百分百投递成功 幂等性 如何避免海量订单生成时消息的重复消费 Confirm确认消息、Return返回消息 自定义消费者 消息的ACK与重回队列 限流 TTL 死信队列 2 保证消息的百分百投递成功 2.1 Producer 的可靠性投递 2.1.1 要求 保证消息的成功发出 保证MQ节点的成功接收 发送端收到MQ节点(Broker) 确认应答 完善的消息补偿机制 在实际生产中,很难保障前三点的完全可靠,比如在极端的环境中,生产者发送消息失败了,发送端在接受确认应答时突然发生网络闪断等等情况,很难保障可靠性投递,所以就需要有第四点完善的消息补偿机制。 2.1.2 解决方案 2.1.2.1 方案一:消息信息落库,对消息状态进行打标(常见方案) 将消息持久化到DB并设置状态值,收到Consumer的应答就改变当前记录的状态. 再轮询重新发送没接收到应答的消息,注意这里要设置重试次数. 方案流程图 方案实现流程 比如我下单成功 step1 - 对订单数据入BIZ DB订单库,并对因此生成的业务消息入MSG DB消息库 此处由于采用了两个数据库,需要两次持久化操作,为了保证数据的一致性,有人可能就想着采用分布式事务,但在大厂实践中,基本都是采用补偿机制! 这里一定要保证step1 中消息都存储成功了,没有出现任何异常情况,然后生产端再进行消息发送

Dont ask confirm if user submit the form

只愿长相守 提交于 2019-11-30 19:56:30
I am using following JavaScript code to warn a user if he tries to redirect to another page without submitting the form. window.onbeforeunload = function() { return 'Are you sure that you want to leave this page?'; }; This is working fine.But my problem is when user trying to submit the form using submit button confirm box will be appear. I don't want to ask the confirm if user submitting the form,otherwise I want to ask confirm. How is it possible? maintain a state variable. when user click submit button set state to userSubmitted=True ; state variable may include a global variable or hidden

Silverlight Confirm Dialog to Pause Thread

爷,独闯天下 提交于 2019-11-30 15:32:14
问题 I'm trying to do a confirmation dialog using Silverlight's ChildWindow object. Ideally, I'd like it to work like MessageBox.Show() , where the entire application halts until an input is received from the user. For example: for (int i = 0; i < 5; i++) { if (i==3 && MessageBox.Show("Exit early?", "Iterator", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { break; } } Would stop the iteration at 3 if the user hits OK... However, if I were to do something along the lines: ChildWindow confirm

Custom confirm dialog with JavaScript

不问归期 提交于 2019-11-30 15:09:44
问题 I would like to create a JavaScript function similar to confirm() that shows a dialog (a div with a question and 2 buttons) and returns true if the user clicks "Ok" or false otherwise. Is it possible to do that using JavaScript/jQuery but without plugins (e.g. jQuery UI or Dialog)? Because I'm trying to reduce size and round trip times... I tried to write this code, but I don't know how to make the function "wait" for the user click. I would like to use my function in this way: answer

Silverlight Confirm Dialog to Pause Thread

风流意气都作罢 提交于 2019-11-30 14:11:13
I'm trying to do a confirmation dialog using Silverlight's ChildWindow object. Ideally, I'd like it to work like MessageBox.Show() , where the entire application halts until an input is received from the user. For example: for (int i = 0; i < 5; i++) { if (i==3 && MessageBox.Show("Exit early?", "Iterator", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { break; } } Would stop the iteration at 3 if the user hits OK... However, if I were to do something along the lines: ChildWindow confirm = new ChildWindow(); confirm.Title = "Iterator"; confirm.HasCloseButton = false; Grid container = new

Custom confirm dialog with JavaScript

梦想与她 提交于 2019-11-30 13:29:04
I would like to create a JavaScript function similar to confirm() that shows a dialog (a div with a question and 2 buttons) and returns true if the user clicks "Ok" or false otherwise. Is it possible to do that using JavaScript/jQuery but without plugins (e.g. jQuery UI or Dialog)? Because I'm trying to reduce size and round trip times... I tried to write this code, but I don't know how to make the function "wait" for the user click. I would like to use my function in this way: answer=myConfirm("Are you sure?") In this way I could use the same function in several contexts, simply changing the

Selenium 2自动化测试实战17(警告框处理)

让人想犯罪 __ 提交于 2019-11-30 09:43:58
一、警告框处理 在WebDriver中处理JavaScript所生成的 alert、confirm以及prompt 十分简单,只需要使用 switch_to_alert() 方法定位到 alert/confirm/prompt ,然后使用 text/accept/dismiss/send_keys 等方法进行操作。 (1)text:返回alert/confirm/prompt中的文字信息 (2)accept():接受现有警告框 (3)dismiss():解散现有警告框 (4)send_keys(KeysToSend):发送文本至警告框。KeysToSend:将文本发送至警告框。 #coding:utf-8 from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.action_chains import ActionChains import time driver=webdriver.Chrome() driver.implicitly_wait(10) driver.get("http://www.baidu.com") #鼠标悬停至设置 link=driver.find_element_by_link_text(u

Javascript - rename confirm() buttons

牧云@^-^@ 提交于 2019-11-30 08:55:39
问题 By default, there are two buttons:"ok" and "cancel" in confirm(). Is there a way to rename them? 回答1: http://dev.w3.org/html5/spec-preview/user-prompts.html#simple-dialogs According to the standard that defines confirm() , there is no way to specify custom button labels. The browser must display an OK/Cancel prompt to comply with HTML5. 回答2: No, there isn't. Confirm only takes one argument and that is the message itself. http://dev.w3.org/html5/spec-preview/user-prompts.html#dom-confirm Keep