MQ Learning (i)----JMS specification (forwarding consolidation)

Source: Internet
Author: User

Recently conducted ACTIVEMQ study, summed up under a rainy days.

JMS Specification:

JMS that is, the Java Message Service Application interface is an API for message-oriented middleware (MOM) in the Java platform for sending messages between two applications, or distributed systems, for asynchronous communication. The Java Messaging Service is a platform-agnostic API, and the vast majority of MOM providers support JMS.

JMS is a vendor-agnostic API used to access messaging system messages. It is similar to JDBC (Java Database Connectivity): Here, JDBC is the API that can be used to access many different relational databases, while JMS provides the same vendor-independent access method to access the messaging service. Many vendors support JMS, including IBM's MQSeries, Bea's Weblogic JMS service, and Progress SonicMQ, which are just a few examples. JMS enables you to send messages from one JMS client to another through a messaging service (sometimes called a message broker or router). A message is a type object in JMS that consists of two parts: a header and a message body. The header consists of the routing information and the metadata about the message. The message body carries the data or payload of the application. Depending on the type of payload, messages can be divided into several types, each carrying: simple text (textmessage), serializable object (objectmessage), attribute collection (mapmessage), Byte Stream (bytesmessage), The original value stream (Streammessage), as well as a message with no payload.

1) connect the factory. The Connection factory (ConnectionFactory) is created by the Administrator and bound to the Jndi tree. The client uses Jndi to find the connection factory and then creates a JMS connection using the connection factory.

2) JMS connection. A JMS connection (Connection) represents an active connection between the JMS client and the server side, which is established by the client by invoking the connection factory method.

3) JMS session. A JMS session (session) indicates the state of the conversation between the JMS client and the JMS server. A JMS session is established on a JMS connection and represents a session thread between the client and the server.

4) JMS purposes. JMS Purpose (Destination), also known as Message Queuing, is the actual source of the message.

5) JMS producers and consumers. The producer (message Producer) and consumer (message Consumer) objects are created by the session object for sending and receiving messages.

6) There are usually two types of JMS messages:

① Point-to-point (point-to-point). In a point-to-point messaging system, messages are distributed to a single consumer. Point-to-point messages are often associated with queues (Javax.jms.Queue).

② Publish/Subscribe (publish/subscribe). The Publish/Subscribe messaging system supports an event-driven model in which message producers and consumers are involved in message delivery. Producers publish events, and consumers subscribe to events of interest and use events. This type of message is typically associated with a specific topic (JAVAX.JMS.TOPIC)

Specific explanations:
The ConnectionFactory interface (connection factory)----The managed object that the user uses to create a connection to the JMS provider. The JMS client accesses the connection through a portable interface so that the code does not need to be modified when the implementation of the current layer changes. The administrator configures the connection factory in the Jndi namespace so that JMS clients can find them. Depending on the message type, the user will use the Queue connection factory, or the subject connection factory.
The Connection Interface (connection)----Connection represents the communication link between the application and the messaging server. Once you have a connection factory, you can create a connection to the JMS provider. Depending on the connection type, the connection allows the user to create a session to send and receive queues and topics to the destination.
The Destination interface (target)----target is a managed object that wraps the message target identifier, which is the location where the message is published and received, or whether it is a queue, or a subject. The JMS administrator creates these objects and then the user discovers them through Jndi. Like a connection factory, an administrator can create two types of targets, a queue of point-to-point models, and a topic for the publisher/subscriber model.
Session interfaces (sessions)----represent a single thread context for sending and receiving messages. Because the session is single-threaded, the message is sequential, meaning that the message is received one at a time in the order in which it was sent. The advantage of a session is that it supports transactions. If the user chooses transaction support, the session context saves a set of messages until the transaction is committed. Users can cancel these messages by using a rollback operation before committing the transaction. A session allows users to create message producers to send messages and create message consumers to receive messages.
The Messageconsumer interface (message consumer)----The object created by the session to receive messages sent to the destination. Consumers can synchronize (block mode), or (non-blocking) messages that receive queues and subject types.
The MessageProducer interface (message producer)----objects created by the session to send messages to the destination. Users can create a sender for a target, or they can create a generic sender that specifies a target when sending a message.
Message interfaces (messages)----are objects that are passed between consumers and producers, that is, from one application to another. There are three main parts of a message:
1. Message header (required): Contains the action settings that are used to identify and find routes for messages.
2. A set of message properties (optional): Contains additional attributes that support compatibility with other providers and users. You can create custom fields and filters (message selectors).
3. A message body (optional): Allows the user to create five types of messages (text messages, map messages, byte messages, stream messages, and object messages).
The messaging interface is flexible and provides many ways to customize the content of the message.

MQ Learning (i)----JMS specification (forwarding consolidation)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.