summarize
JMS (Java Messaging Services), is used to establish a network for successful communication between multiple units and applications within a given system. Typically, it takes the form of an application program interface that passes messages from one application to another with the help of a queue path.JMS has the following characteristics:
- It is an API interface protocol that sends messages from one application to another.
- Assuming that one application server is located in China and another application is located in another country, JMS creates messages and sends them from the host application to the recipient application that receives them.
- JMS consists of a queue in which it creates a message from an application and the message will sit in the queue until the recipient application receives it.
A simple one-sentence description is: The Java Messaging Service (JMS) API is a messaging standard that allows for the use of a Java Platform Enterprise Edition (Java EE) application components to create, send, receive and read messages. It supports loosely coupled, reliable and asynchronous distributed communication
Development History
The Java Messaging Service was developed by Sun Microsystems (acquired by Oracle on April 20, 2009) and is part of the Enterprise Edition of the Java platform.The first version of JMS, JMS 1.0.2b, was released on June 26, 2001.The stable version of JMS is JMS 2.0, released on May 21, 2013
- JMS 1.0
- JMS 1.0.1 (October 5, 1998)
- JMS 1.0.1a (October 30, 1998)
- JMS 1.0.2 (December 17, 1999)
- JMS 1.0.2a (December 23, 1999)
- JMS 1.0.2b (August 27, 2001)
- JMS 1.1 (April 12, 2002)
- JMS 2.0 (May 21, 2013)
- JMS 2.0a ( March 16, 2015)
the Java Community Process Maintain JMS 2.0 named JSR 343.
JMS Technical Specifications
messaging model
JMS provides support for both peer-to-peer (P2P) and publish/subscribe (Pub-Sub) domains, and some JMS clients use a combination of both domains in a single application
Peer-to-Peer (P2P)

- This is a method of communication in which the sender (the person who creates and sends the message) can only send the message to one receiver (the recipient who receives the message) at a time.
- This method uses a queuing mechanism in which messages are sent to a queue, i.e., a destination. The sender sends the message to the target, and the receiver in the target can use the message.
- It is important that the receiver is registered to the target, otherwise the receiver will not be able to use the message.
- If no receiver is registered to the target, the message will sit in the target until any receiver registers with the target to receive it.
- No sender can send a message, but a receiver can use the message
Publish/Subscribe (Pub-Sub)

- This method of communication allows a sender to communicate a message to many recipients.
- Unlike queues, it uses topics as destination points.
- Therefore, in this method, all users must subscribe to the target point.
- After the message is sent from the sender to the destination, it is available to all active recipients subscribed to the Topic.
- Unlike a queue, a topic destination cannot hold messages unless the subscribed user is inactive at the time the message is delivered.
- Such subscriptions are called persistent subscriptions.
JMS Model Architecture
The JMS system consists of the following components

- JMS Provider: A messaging system that implements the JMS specification.
- JMS Clients: Java applications that send and receive messages.
- Messages: Objects used to pass messages between JMS clients.
- Administered Objects: Pre-configured JMS objects created by an administrator for use with a JMS client.
JMS Programming Model
A JMS application consists of a set of application-defined messages and a set of clients that exchange those messages.JMS clients interact by sending and receiving messages using the JMS API. A message consists of three parts: header flags, attributes, and body.
- The header, which is required for every message, contains information used to route and identify the message. Some of these fields are set automatically by the JMS provider during message generation and delivery, while others are set by the client on a message-by-message basis.
- Properties are optional and provide values that the client can use to filter the message. They provide additional information about the data, such as the process that created the data, and when the data was created. Properties can be thought of as an extension of the header and consist of property name/value pairs. Using attributes, clients can fine-tune their message selection by specifying certain values that act as selection criteria.
- The body is also optional and contains the actual data to be exchanged.The JMS specification defines six types or message classes that must be supported by JMS provider programs:
- Message: This indicates a message without a message body.
- StreamMessage: Its body contains messages of the Java primitive type stream. It is written and read sequentially.
- MapMessage: its body contains a set of name/value pairs. The order of the entries is not defined.
- TextMessage: the body of which contains a Java string message...such as an XML message.
- ObjectMessage: Its body contains messages that serialize Java objects.
- BytesMessage: its body contains the message of the uninterpreted byte stream.
JMS Interface Programming
- ConnectionFactory interface: (Connection Factory) the factory to create a Connection, depending on the type of message the user can choose to use the queue connection factory or use the topic connection factory corresponds to QueueConnectionFactory and TopicConnectionFactory respectively.
- Destination interface: Destination is an authorized object wrapped with a message destination identifier. Message destinations are: places where messages are published and messages are received, either queues or topics. There are two main types of objects Queue and Topic
- Connection interface: Connection represents the connection established between the client and the JMS system (actually corresponds to the TCP/socket) package, Connection can correspond to one or more Session, Connection and connection factory, there are also two types: QueueConnection and TopicConnection.
- Session Interface:Session is the interface that actually manipulates messages, representing a single-threaded context for sending and receiving messages.Session is also divided into QueueSession and TopicSession.
- MessageProducer Interface:MessageProducerSession is created and used to send messages to Destination.Consumers can be either synchronous or asynchronous to receive messages of Queue and Topic types. There are two types of producers, QueueSender and TopicPublisher.
- MessageConsumer interface:Message consumers are created by Session to receive messages sent to Destination. There are two types of consumers: QueueReceive and TopicSubscriber.
- Message interface: the object that messages are passed between consumers and producers
- MessageListener:MessageListenerIf a message listener is registered, then the onMessage method of the listener will be called automatically when the message is reached.
resource (such as manpower or tourism)
JSR 343: Java Message Service 2.0
Content review.