EBU6501 Middleware
TB1
1.1 MOM(Messge-Oriented Middleware) 面向消息的中间件
Messaging
-
Messaging is a method of communication between software components or
applications.
-
A messaging system:peer to peer (P2P)点对点
-
Messaging enables distributed communication that is loosely coupled
消息传递支持松散耦合的分布式通信
-
Sender和receiver不需要知道对方的任何信息,除了要使用什么消息格式和目的地之外
-
不同于 tightly coupled 紧密耦合的通信技术 比如 Remote Method Invocation (RMI)(远程方法调用):要求应用程序知道远程应用程序的方法。
-
也不同于e-mail:是人与人或人与应用程序间的通信。
-
Messaging is used for communication between software applications or software components 消息用于应用程序之间或软件组成之间的通信
Messaging Services
-
A message service : **software component functionality **软件组件的功能
-
一种**peer to peer(P2P)**通信
-
每个组件既是client也是server
-
sender只需要知道要发送的数据格式和receiver的目的地
-
loosely coupled cimmunication 松散耦合
Advantages of Messaging
- Heterogeneous Integration 异构集成
- 意味着messaging是middleware的一种形式
- Reduce System Bottlenecks 缓解系统瓶颈
- Increase Scalability 增大规模
Messaging Service的类型
- Cloud Messaging Service
- Cloud solution
- Short Message Service(SMS)
- Text messaging service
- Instant Message Service(IMS)
- online chart messaging system
- Multimedia Message Service(MMS)
- extend SMS
Cloud-Based Messaging Services举例
Google Cloud Messaging (GCM) Service;Google Cloud Messaging (GCM) Service;Java Messaging Service (JMS);Xiaomi MIUI Cloud Messaging Service
Message oriented Middleware (MOM)
定义:
Message-oriented Middleware (MOM) is a software or hardware that provides a communication channel between **heterogeneous **applications, platforms and systems by passing messages across between the communicating systems.
面向消息的中间件(MOM)是一种软件或硬件,它通过在通信系统之间传递消息,在异构应用程序、平台和系统之间提供一个通信通道。
- MOM uses the eXtensible Messaging and **Presence Protocol (XMPP) **for communication 可扩展消息传递和状态协议(XMPP)
- 提供异步通信
MOM 结构
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eTBFTeWV-1640226990834)(/Users/mac/Library/Application Support/typora-user-images/image-20211217130749774.png)]
MOM Client - Producer
- Client使用“Message Producer”产生消息,然后由“Message Producer”发送,消息通常发送到physical目的地,该目的地使用目的地对象写入API中。
Message Broker
- broker负责接收和发送消息
- facilitates the connections
- 使用加密的SSL验证连接 secure connection
MOM Client - Consumer
- MOM使用异步消费方法:消息被自动传给“Message Listener”对象,被consumer定义。
- 或者,消息只能被消息使用,配合comsumer选择的特性
- Client使用API调用以发送消息
- 消息发送至povider管理的目的地。该调用调用provider服务来route和
传达消息。 - 一旦发送了消息,client可以继续其他的工作,相信provider会保留消息直到receiving client检索它。
MOM的类型
- Message Queuing
- Publish/Subscribe 发布/订阅
MOM Implementation Models MOM实现模型举例
-
Microsoft’s Message Queuing (MSMQ)
-
Oracle’s Java Messaging Service (JMS)
-
IBM’s WebSphere Message Queuing (WebSphere MQ)
-
Sonic Message Queuing (Sonic MQ)
*(考:20/21A)*MOM‘s Messaging Models 两种消息模型
- Point-to-Point(P2P)
- One-to-one
- 一个sender一次只向一个receiver发送消息,client向特定队列发送消息,消息被发送到client指定的特定地址,receiver需要知道消息正在被发送
- Publish/Subscribe(Pub/Sub)
- One-to-many 或 many-to-many
- 许多接收者或许多消息被许多接收者发送和接收,消息的sender和receiver是分离的
MOM的优点
- Hides the complexity of applications
- 发送和接收消息的方式reliable
- MOM嵌入了security features,因此消息无法被拦截和改变
- 发送消息异步 asynchronously
- 允许异构系统heterogeneous systems
- 允许不同编程语言跨平台移植ported(portability)
Publish-Subscribe
Pub/Sub Message类型
- Topics-Based
- Content-Based
- Type-Based
Topics-Based
- 分层命名:hierarchical naming
- Logical arrangement
- 特定名词
- 专用序列
- 缺点:由于使用特定名词,所以限制太大
Content-Based
- 不使用特定名词
- query-like
- 优点:限制少,因为不使用特定名词
Type-Based
- subscribers需要注册
- 消息表示为objects
- 缺点:有限制,因为用户需要注册以获取想要的信息类型
Publish/Subscribe Subscription Model
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-SeRNjS9A-1640226990835)(/Users/mac/Library/Application Support/typora-user-images/image-20211217144536609.png)]
Security in MOMs
- IBM uses System Authorisation Facility (SAF) to control access to MOM
- Encrypted Messages 加密消息
MOM的Queuing Systems类型
- First-In-First-Out(FIFO)
- FIFO with Priorties 有优先级的
- Journal Queue
- Public Queue
- Private Quene
- Connector/Bridge
1.2 Java Messaging Service(JMS)
JMS API介绍
- JMS is a Java Application Programming Interface (API) that allows applications to create, send, receive and read messages
- JMS API允许松散耦合和异步通信:loosely coupled communication和asynchronous communication
- reliable,确保消息只传递一次
- 希望组件不依赖关于组件接口的信息,使组件易于替换(松散耦合)
- provider希望组件同时运行(异步通信)
JMS API 架构
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-PEKCFGcv-1640226990836)(/Users/mac/Library/Application Support/typora-user-images/image-20211217151504749.png)]
-
JMS Provider
-
JMS Clients
-
Messages
-
Ad