Using JMS to build a messaging system

Source: Internet
Author: User
Tags message queue

In order to understand this article, we want the reader to have a fairly solid foundation for Java programming before we begin. We will try to explain what JMS is as simple as possible, but before you can build your own programs and understand them correctly, you need to have some experience using Jndi to develop the actual application.

JMS (Java Messaging Service) is a message exchange standard that allows you to create, send, receive, and read messages using the Java EE application component. It assumes that distributed communication has free, reliable (reliable) and asynchronous (asynchronous) connections.

Exchange (Swap) system

Message exchange reflects an interaction between program components or applications. A message exchange system is a similar system: a client of a similar system can send and receive messages from any other client. Each client is incorporated into the system's proxy, which provides the possibility to establish, send, receive, and read messages.

Switching systems make it possible to distribute interactive operations. The component sends a message at the destination (destination), and the recipient can get the message from the same destination. The sender and recipient are not necessarily familiar with each other. In other words, it does not force the sender to know some of the recipient's information, nor does it force the recipient to know some of the sender's information. The sender and the recipient only need to know the format of the message and the destination to be reached. In this case, the system is different from some of the technologies that are closely connected to it, such as remote Method Invocation (RMI), which only requires the developer to understand some of the methods in RMI.

Message delivery system

The messaging system is a distributed system based on asynchronous message exchange between system components. Message-oriented middleware (message-oriented middleware,mom) is the product, the messaging system is built on its principles.

Messaging system applications do not communicate directly (this is in stark contrast to traditional systems (RMI) and rely on the help of MOM. If a component of the system wants to send a message to another component, it sends the given message to MOM, and then MOM sends the message to the recipient.

Compared with the traditional RMI based system, it has the following advantages:

• The application that sends the message does not need to expect a response and can continue execution.

· The recipient of an application and a specific message that is not forced to send a message is activated at a particular time. If the recipient of the message is not active, MOM guarantees that the recipient will receive the message as soon as it is activated.

· System components are not directly connected to each other. They are separated, which is why they can transfer components from one host to another without disrupting system availability at run time.

Message exchange Model: Point-to-Point model and publish-subscribe model

There are currently two "basic" message exchange models: the point-to-point model and the publish-subscribe (PUB-SUB) model. The point-to-point model applies to the case where one or more components (the sender) send messages to only one component recipient (recipient). This model is based on the concept of Message Queuing: The sender sends the message to the queue, and the recipient reads the message from the queue. In a point-to-point model, multiple receivers may exist on the same queue, but MOM sends messages only to one of them. Which delivery message depends on the implementation of MOM (Implementation).

Publish-the subscription model applies to situations where one or more components (the Publisher) send messages to one or more component recipients (subscribers). This particular model is based on the concept of message topic: A publisher sends a message to a topic, and the subscriber of that particular topic receives the message.

Publish-The booking model looks more "elegant", but many publishing-subscription models do not guarantee that messages are delivered in the order in which they are sent (it is in contrast to the point-to-point model, the point-to-point queue implements the FIFO (first-in first Out) principle). Therefore, the order of messages is important (or to synchronize the header and attribute parts of the message), you should avoid the publish-subscribe model.

Java Messaging Service (JMS) is a set of Java APIs that use message-oriented middleware, which allows your application to establish, send, receive, and read messages. This set of assemblies is located in the JAVAX.JMS package on the Java-EE package structure tree. JMS is implemented in many MOM products, including iplanet message Queue, IBM MQSeries, Progress Software sonicmq, BEA WebLogic Server, Prism Technologies Openfusion and so on the most famous, there are some free implementation.

JMS also supports two "basic" models of message exchange. However, its description (specification) does not require vendors to implement both models simultaneously, although most JMS products implement a point-to-point and publish-subscribe model.

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.