简体   繁体   English

何时选择基于UDP套接字API的JMS API,反之亦然?

[英]When to choose JMS API over UDP socket API or vice versa?

What are the reasons that can motivate a programmer to use Java JMS (Java Message Service) API instead of UDP socket API of the java.net package in a distributed Java application or to use UDP socket API instead of JMS API? 是什么原因可以激励程序员在分布式Java应用程序中使用Java JMS(Java消息服务)API而不是java.net包的UDP套接字API,或者使用UDP套接字API代替JMS API? If possible, please give example applications. 如果可能,请举例说明。

UDP and JMS are different in many ways, and fundamentally since JMS typically relies on the features inherent to TCP (see this comparison of UDP and TCP to get an idea of the differences of the two underlying protocols). UDPJMS在很多方面都有所不同,从根本上说,因为JMS通常依赖于TCP固有的特性(参见UDP和TCP的比较以了解两种底层协议的差异)。

Basically UDP is suitable for applications which do not require any reliability, ordering, congestion control, or routing between networks (since many consumer and commercial grade routers do not forward UDP packets). 基本上UDP适用于不需要任何可靠性,排序,拥塞控制或网络之间路由的应用程序(因为许多消费者和商业级路由器不转发UDP数据包)。 JMS provides all of these features missing from UDP and more (like transactions, pub/sub and queueing, durable subscriptions, etc). JMS提供了UDP及其他所有缺少的功能(如事务,发布/订阅和排队,持久订阅等)。

UDP might be appropriate for streaming large amounts of data within a local area network where absolute quality is not a requirement; UDP可能适合在局域网内传输大量数据,而不需要绝对质量; JMS would be better for applications requiring reliable messaging between wide area network hosts. 对于需要在广域网主机之间进行可靠消息传递的应用程序,JMS会更好。 Moreover, JMS obscures the details of sockets, servers, binding, etc. and provides a high-level API which is better suited for enterprise integration. 此外,JMS模糊了套接字,服务器,绑定等的细节,并提供了更适合企业集成的高级API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM