jms 教程
Nowadays, most of the enterprise applications are using messaging concept for asynchronous communication between heterogeneous applications using JMS or AMQP. I’m going to deliver a series of posts to discuss these concepts in detail with real-time examples in my coming posts.
如今,大多数企业应用程序都使用消息传递概念在使用JMS或AMQP的异构应用程序之间进行异步通信。 我将在以后的文章中提供一系列文章,以实时示例的形式详细讨论这些概念。
JMS (JMS)
- JMS is the acronym for Java Messaging System. JMS是Java Messaging System的首字母缩写。
- JMS is part of Java EE. JMS是Java EE的一部分。
- JMS API is the implementation to handle the producer-consumer problem. JMS API是处理生产者-消费者问题的实现。
- JMS API allows us to create, send, receive, and read messages. JMS API允许我们创建,发送,接收和阅读消息。
- Some o the benefits of using JMS are – loosely coupled application, reliability, and asynchronous communication. 使用JMS的一些好处是–松散耦合的应用程序,可靠性和异步通信。
什么是讯息? (What is Message?)
The message is a piece of information. It can be a text, XML document, JSON data or an Entity (Java Object) etc. The message is very useful data to communicate between different systems.
该消息是一条信息。 它可以是文本,XML文档,JSON数据或实体(Java对象)等。消息对于在不同系统之间进行通信非常有用的数据。
什么是消息传递? (What is Messaging?)
Messaging means exchanging information between different components in the same system or different systems. It can happen in either a synchronous manner or an asynchronous manner.
消息传递是指在同一系统或不同系统中的不同组件之间交换信息。 它可以以同步方式或异步方式发生。
什么是JMS? (What is JMS?)
JMS stands for Java Message Service. JMS API is a Java API which contains a common set of interfaces to implement enterprise based messaging systems. JMS API is used to implement Messaging systems in Java-based applications only, it does not support other languages.
JMS代表Java消息服务。 JMS API是Java API,其中包含一组通用接口,以实现基于企业的消息传递系统。 JMS API仅用于在基于Java的应用程序中实现消息系统,它不支持其他语言。
JMS API is used to create, send, receive and read messages or exchange messages between different systems. Once we develop a Java Messaging System with JMS API, then we can deploy the same application in any JMS Provider software.
JMS API用于在不同系统之间创建,发送,接收和读取消息或交换消息。 一旦我们使用JMS API开发了Java消息系统,就可以在任何JMS Provider软件中部署相同的应用程序。
An Enterprise Application may have ‘n’ number of components and they are exchanging messages by using one of the Messaging System as shown below.
企业应用程序可能具有“ n”个组件,并且它们正在使用消息系统之一来交换消息,如下所示。
Some Enterprise applications may have ‘n’ number systems and they exist in different locations. They use different platforms. If they want to exchange information in a loosely coupled manner, then we should use JMS Messaging system.
某些企业应用程序可能具有n个编号系统,并且它们存在于不同的位置。 他们使用不同的平台。 如果他们想以松散耦合的方式交换信息,那么我们应该使用JMS Messaging系统。
JMS的优势 (JMS Advantages)
- Loosely Coupled: We can develop loosely coupled applications very easily. That means JMS API is standard or specification that should be implemented by all JMS Providers so that we can change existing JMS Provider to new JMS Provider with little changes (that means only configurations) or without changing our JMS Application code. 松耦合 :我们可以很容易地开发松耦合应用程序。 这意味着JMS API是所有JMS提供程序都应实施的标准或规范,以便我们可以将现有的JMS提供程序更改为新的JMS提供程序,而只需进行很少的更改(即仅配置),而无需更改我们的JMS应用程序代码。
- Asynchronous: We can develop asynchronous messaging applications very easily. That means JMS Sender can send messages and continue on its own work. It does not wait for the completion of message consumption by JMS Receiver. 异步 :我们可以非常轻松地开发异步消息应用程序。 这意味着JMS Sender可以发送消息并继续自己的工作。 它不等待JMS Receiver完成消息使用。
- Robust and Reliable: JMS ensures that a message is delivered one and only once to the destination system. So we can develop reliable applications very easily. 健壮且可靠 :JMS确保将一条消息仅传递到目标系统一次。 因此,我们可以非常轻松地开发可靠的应用程序。
- Interoperability: JMS API allows Interoperability between other Java Platform languages like Scala and Groovy. 互操作性 :JMS API允许其他Java平台语言(例如Scala和Groovy)之间的互操作性。
JMS组件 (JMS Components)
A typical JMS system contains the following components:
典型的JMS系统包含以下组件:
- JMS Client: Java program used to send (or produce or publish) or receive (or consume or subscribe) messages. JMS客户端 :用于发送(或产生或发布)或接收(或使用或订阅)消息的Java程序。
- JMS Sender: JMS Client which is used to send messages to the destination system. JMS sender is also known as JMS Producer or JMS Publisher. JMS Sender :用于将消息发送到目标系统的JMS客户端。 JMS发送者也称为JMS生产者或JMS发布者。
- JMS Receiver: JMS Client which is used to receive messages from Source system. JMS Receiver is also known as JMS Consumer or JMS Subscriber. JMS接收器 :JMS客户端,用于从源系统接收消息。 JMS接收器也称为JMS使用者或JMS订阅者。
- JMS Provider: JMS API is a set of common interfaces, which does not contain any implementation. JMS Provider is a third-party system who is responsible to implement the JMS API to provide messaging features to the clients.
JMS Provider is also known as MOM (Message Oriented Middleware) software or Message Broker or JMS Server or Messaging Server. JMS Provider also provides some UI components to administrate and control this MOM software.
JMS Provider :JMS API是一组通用接口,不包含任何实现。 JMS Provider是第三方系统,负责实施JMS API以向客户端提供消息传递功能。JMS Provider也称为MOM(面向消息的中间件)软件或Message Broker或JMS Server或Messaging Server。 JMS Provider还提供了一些UI组件来管理和控制此MOM软件。
- JMS Administered Objects: JMS Objects which are preconfigured by an administrator for the use of JMS clients. They are ConnectionFactory and Destination Objects. JMS管理对象 :管理员为使用JMS客户端而预先配置的JMS对象。 它们是ConnectionFactory和目标对象。
- ConnectionFactory: ConnectionFactory object is used to create a connection between Java Application and JMS Provider. It is used by Application to communicate with JMS Provider. ConnectionFactory :ConnectionFactory对象用于在Java应用程序和JMS Provider之间创建连接。 应用程序使用它与JMS Provider进行通信。
- Destination: Destinations are also JMS Objects used by a JMS Client to specify the destination of messages it is sending and the source of messages it receives. There are two types of Destinations: Queue and Topic. 目标 :目标也是JMS客户端使用的JMS对象,用于指定其发送的消息的目的地和接收的消息的源。 有两种类型的目标:队列和主题。
- JMS Message: an object that contains the data being transferred between JMS clients. JMS消息 :一个对象,其中包含在JMS客户端之间传输的数据。
最受欢迎的JMS提供者 (Most popular JMS Providers)
S.No. JMS Provider Software Organization 1. WebSphere MQ IBM 2. Weblogic Messaging Oracle Corporation 3. Active MQ Apache Foundation 4. Rabbit MQ Rabbit Technologies(acquired by Spring Source) 5. HornetQ JBoss 6. Sonic MQ Progress Software 7. TIBCO EMS TIBCO 8. Open MQ Oracle Corporation 9. SonicMQ Aurea Software 序号 JMS Provider软件 组织 1。 WebSphere MQ IBM公司 2。 Weblogic消息传递 Oracle公司 3。 主动MQ 阿帕奇基金会 4。 兔子MQ Rabbit Technologies(由Spring Source收购) 5, 大黄蜂 老板 6。 音速MQ 进度软件 7 TIBCO EMS 泰科 8。 打开MQ Oracle公司 9。 SonicMQ Aurea软件 JMS API的历史 (History of JMS API)
S.No. JMS API Version Released Date 1. JMS 1.0.2 June 2001 2. JMS 1.1 March 2003 3. JMS 2.0 May 2013 序号 JMS API版本 发布日期 1。 JMS 1.0.2 2001年6月 2。 JMS 1.1 2003年3月 3。 JMS 2.0 2013年5月 结论 (Conclusion)
JMS API is a robust way to implement a messaging system in our applications. There are various popular JMS providers including AMQP from Spring framework.
JMS API是在我们的应用程序中实现消息传递系统的可靠方法。 有许多流行的JMS提供程序,包括Spring框架的AMQP。
Reference: Wikipedia Article
参考: 维基百科文章
jms 教程