Skip to Content
Python语言及其应用(第2版)
book

Python语言及其应用(第2版)

by Bill Lubanovic
March 2022
Intermediate to advanced
522 pages
13h 52m
Chinese
Posts & Telecom Press
Content preview from Python语言及其应用(第2版)
302
17
Apache
项目(
18.2.4
节会介绍该项目的
Web
服务器)还维护着
ActiveMQ
项目,其中
包括采用简单文本
ST
OMP
协议的多种
Python
接口。
RabbitMQ
也是一款流行的消息工具,其在线
Python
教程还不错。
NATS
是用
Go
编写的快速消息系统。
17.4
发布
订阅
模式
“发布
订阅”并不是队列,而是广播。一个或多个进程发布信息,每个订阅进程声明自
己要接收的消息类型。对应类型的消息副本会被发送给所有订阅者。因此,指定消息可能
会被处理一次或多次,还可能一次都不处理。就像孤独的无线电操作员,每个发布者只负
责广播,并不知道谁(如果有人的话)在侦听。
17.4.1 Redis
16
章介绍过
Redis
,当时主要是作为数据结构服务器,但它也包含了一个“发布
阅”系统。发布者会发出包含话题和值的消息,订阅者会指明自己想接收的话题。
17-7
包含了发布者的代码
redis_pub.py
17-7
redis_pub.py
import redis
import random
conn = redis.Redis()
cats = ['siamese', 'persian', 'maine coon', 'norwegian forest']
hats = ['stovepipe', 'bowler', 'tam-o-shanter', 'fedora']
for msg in range(10):
cat = random.choice(cats) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python编程入门与实战

Python编程入门与实战

Posts & Telecom Press, Fabrizio Romano
Python实用技能学习指南

Python实用技能学习指南

Posts & Telecom Press, Robert Smallshire, Austin Bingham
Python技术基础视频教程

Python技术基础视频教程

保罗·J·戴特尔
Python面向对象编程指南

Python面向对象编程指南

Posts & Telecom Press, Steven F. Lott

Publisher Resources

ISBN: 9787115586223