小白写给菜鸟看的MQ简介
Posted _
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小白写给菜鸟看的MQ简介相关的知识,希望对你有一定的参考价值。
function handle_register() add_user(); send_sms(); // 发送手机短信,耗时5秒 show("注册成功。"); // 缺点:性急的用户还以为注册失败。 function handle_register() add_user(); // publish把消息放进队列里后立刻返回。另一个程序/进程不断地从消息队列里取消息并处理(发送短信)。 publish(body=\'send_sms\'); show("注册成功。 请先随便逛逛,过一会您会收到短信。");
矩阵相乘慢可以使劲优化,有些事则不可控。用户界面上可做些处理,比如下载文件显示进度条,大屏幕/手机app显示排队的还有多少人,公交车还有多长时间到。
最开始就一个程序,send_sms是同一个程序里的一个函数function. 为了和sin(), cos()之类区别,有些编程语言把不返回值只干事的函数/一段代码叫做过程procedure. 我们可以把这个叫做Internal Procedure Call.
为了搞清楚程序崩了是谁的责任,可以把send_sms做成另外一个程序,两个进程之间通信,Inter Process Communication. 同一个缩写词acronym/abbreviation有不同的意思是IT界的传统,硬件也不例外,如RTL. 公平地说,概念太多,字母不够用。
进程间通信有很多种方式,从很底层的共享内存到message queue. Based on Unix, POSIX (Portable Operating System Interface) is a set of standard OS interfaces. POSIX Message Queue提供mq_open(), mq_send(), mq_notify()等函数。
最初我们直接调用send_sms。现在它独立了,我们只能给它发消息。不处理消息是它的错。我们可以给这个起名Local Procedure Call. 可以说它处理我们发来的消息,也可以两步并作一步,依然看作我们调用它。
接下来一台服务器不够用,我们的程序和send_sms在不同的服务器上运行,算是Remote Procedure Call (RPC)的一种。Sun Microsystems\'s invented RPC in mid 80th. The original version of RPC was defined in RFC 1050. RPC is a powerful technique for constructing distributed, client-server based applications. Local Area Network是局域网,广域网是WAN.
大家都需要的功能应该做成一个工具/库啥的,所以就有了好些家MQ. 本小白一个都没有用过,只粗略地看过点资料:
RabbitMQ is the most widely deployed open source message broker. 用ErLang语言写的。它的文档好理解,例子多,支持的客户端语言多。RabbitMQ is a message broker [掮客qiánkè]: it accepts and forwards messages. You can think about it as a post office: when you put the mail that you want posting in a post box, you can be sure that the letter carrier will eventually deliver the mail to your recipient. In this analogy, RabbitMQ is a post box, a post office, and a letter carrier. The major difference between RabbitMQ and the post office is that it doesn\'t deal with paper, instead it accepts, stores, and forwards [转发] binary blobs of data-messages. 其实blob是binary large object的缩写。binary binary large objects?
ZeroMQ可能是最快的消息队列。C++写的。它有非中间件模式,你的程序(比如send_sms)是主程序,ZeroMQ是库。mq_open, mq_send等,操作系统内置broker. ZeroMQ仅提供非持久性的队列,宕机则数据丢失。Keyspace notifications allow clients to subscribe to Pub/Sub channels in order to receive events affecting the Redis data set in some way. Inotify is a feature built-in to the Linux kernel. In Windows, filesystem changes are exposed via the Win32 Directory Change Notifications API or the.NET FileSystemWatcher API.
rabbitMQ, activeMQ, zeroMQ, Kafka, Redis 比较 - 博客园
NetMQ is a 100% native C# port of ZeroMQ.
Go+LevelDB做个Yet Another MQ不知行不,中文名叫呀!MQ. :-) 比如一个线程疯狂地收消息和写数据库,另一个读数据库和慢悠悠地发短信。
操作系统课上讲了生产者消费者模型。MQ的发布订阅更复杂,比如发布一条消息激活多个订阅者;消息可长期保存。GoF的设计模式里好像没讲MQ,但我记得有发布和订阅。
电信业里ErLang还有这个意思:An Erlang is a unit of telecommunications traffic measurement. It is used to describe the total traffic volume of one hour. Agner Krarup Erlang was born in 1878 in Lønborg, Denmark. He was a pioneer in the study of telecommunications traffic and, through his studies, proposed a formula to calculate the fraction of callers served by a village exchange that would have to wait when attempting to place a call to someone outside the village. In 1909, he published his first work: The Theory of Probabilities and Telephone Conversations.
六级/考研单词: sinister, abbreviation, deploy, broker, carrier, analogy, differentiate, telecommunications, strict, perpetual, pioneer, fraction, converse
以上是关于小白写给菜鸟看的MQ简介的主要内容,如果未能解决你的问题,请参考以下文章