Basic concepts of JMS Learning (I) and basic concepts of jms Learning

Source: Internet
Author: User
Tags enterprise integration patterns

Basic concepts of JMS Learning (I) and basic concepts of jms Learning

I interviewed one or two companies over the past two days. Due to the use of JMS in the most recent project in my resume, the interviewer seems to be very interested in this, so I was asked, but unfortunately, in addition to using JMS, I had a poor answer to some of their questions about JMS. The direct result was an interview failure. At the same time, I also deeply felt that I had a very superficial grasp of the technology, and decided to study JMS first in the spirit of getting up and down from where I fell. This is not only for interviews, but also for in-depth understanding of this framework as much as possible.

This article mainly introduces some basic concepts.

 

  • 1. Introduction to JMS

JMS is short for Java Message Service, that is, Java Message Service. What is MnS? Let's take a look at the official definition of Oracle:

The Java Message Service (JMS) API isMessaging standardThat allows application components based on the Java Platform Enterprise Edition (Java EE) to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, andAsynchronous.

JMS is a message standard that allows Java ee-based application components to create, send, receive, and read messages. With JMS, You can implement loose coupling, dependency, and asynchronous distributed communication. In this section, we should pay attention to two points: first, this is a standard, similar to the Servlet standard, not a specific implementation. Secondly, this is a distributed communication mechanism and is asynchronous.

  • Ii. Version

I did not pay attention to this issue before, but I did not expect to be asked during the interview. I asked which version is used by the JMS protocol. I will check it back, there were two important versions in the history of JMS. One is JMS1.1, and the other is JMS2.0. So what is the difference between the two versions? I found the answer from the Internet and sorted it out as follows:

1. Simplified API: JMS2.0 provides some simplified APIs to simplify code writing so that we can easily create producer and consumer content. Specifically, the new JDK1.7 syntax is used.

2. Simplified configuration: Easier configuration

3. it is important to support multiple consumers to share topics: Because topics are used in my project, the interviewer asked how to allow multiple nodes to consume messages of the same Topic repeatedly. In fact, it can be done through Topic sharing. This is the feature provided by JMS2.0. Of course, if it is 1.1, it seems that selector can also be used.

4. The value of JMSXDeliveryCount must be set. This value indicates the number of retries. Normally, it is 1. If the value is greater than 1, it indicates that the resend is repeated.

 

Which version does our common MQ support currently? Taking ActiveMQ as an example, the official documents are described as follows:

Apache ActiveMQ is fast, supports Cross Language Clients and Protocols, comes with easy to use Enterprise Integration Patterns and advanced features while fully supporting JMS 1.1 and J2EE 1.4. apache ActiveMQ is released under the Apache2.0 License

It seems that ActiveMQ does not support JMS2.0, so the current version of JMS we are using is still 1.1. In the next series, we will introduce the concept and usage of JMS Based on JMS1.1.

  • Iii. Glossary

When talking about JMS, we usually talk about some terms and explain them as follows:

1. message-oriented middleware (JMS Provider): a third-party component that provides the JMS protocol. For example, ActiveMQ is a message-oriented middleware, and KFA and Rabbit MQ are well-known.

2. Message mode: divided into Point-to-Point (P2P) and publish/subscribe (Pub/Sub). The corresponding data structures are Queue and Topic respectively)

3. Message: the carrier of the communication content. Its structure is mainly divided into the Message header, attributes, and Message body. There are several types based on the storage structure, which will be detailed later.

4. Message producer: the producer of the message. In P2P mode, it refers to the message Sender, and in P/S mode, it refers to the Message Publisher (Publisher)

5. Message consumer: the recipient of the message. The two modes correspond to the Receiver and Subscriber respectively)

There are several important interfaces in the standard JMS protocol, which are listed below:

1. ConnectionFactory: create a Connection factory. Use this object to create a Connection to a message service.

2. Connection: a specific Connection created by ConnectionFactory

3. Session: an interface created by Connection to operate messages. This interface can be used directly to create producer objects of messages.

4. destination: the location where the message is stored. The sender sends the message to the specified location and the consumer obtains the message from the specified location. Therefore, the specified location may be a topic or a queue.

5. MessageProducer: Message producer, including QueueSender and TopicPublisher

6. MessageConsumer: the consumer of the message, including QueueReceiver and TopicSubscriber.

7. MessageListener: Message listener, which is provided for consumers to listen to messages. After a listener is added, the onMessage method is called once consumption arrives.

 

  • Iv. Summary

 

This article briefly introduces some concepts of JMS and provides a preliminary understanding of JMS. Some terms and concepts described in this article will be described in detail in subsequent articles.

 

 

 

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.