JMS Basic concepts and scenarios _JMS

Source: Internet
Author: User
Tags soap xpath
Kimmking: Introduction to JMS and ACTIVEMQ. Before we talk about JMS, let's talk about the background. Who knows what JMS means.

Kimmking: Yes, the message service. So, what's the message? Yes, that's the message.

Kimmking:: All the information, we can say is the message.

Kimmking: The premise is that it must be dynamic, fluid, or transitive. This process is messaging.

Everyone: What is the difference between JMS messaging and commonly used communication protocols?

A: Communication protocols are generally designed for a specific communication business scenario, and a provision is made. is a need for many parties to follow. The JMS message mechanism defines a message-passing protocol at a more abstract and generic level. The applicable scenario is different.

Everyone: Go on.


Kimmking:ok, how to describe the message, how to pass the message. With these questions in mind, the JMS specification comes out.

The KIMMKING:JCP organization defines the jsr914 specification for 02-03 years, http://jcp.org/en/jsr/detail?id=914

kimmking:jsr914 is the JMS specification.

Kimmking: There are two main things to do, defining common message formats, and message delivery patterns.

Kimmking: What should a common message format look like?

Everyone: what kind of ~.

Kimmking: message Header message body

Everyone: The head of the subject like this? Similar to soap.

Kimmking: Yes, similar to soap, mainly divided into header,properties,body

Everyone: What's the difference between that and soap?

Kimmking: That's the 8th page of PPT.

Kimmking:soap describes the format of the data in XML format. Focus on RPC, which makes up a system with WSDL.

KIMMKING:JMS describes more general messages.

Kimmking: Or it can be said that SOAP focuses on remote service invocation, and JMS focuses on information exchange.

Kimmking:soap is a two-point connection system, and JMS is 3 dots.

Both Kimmking:header and properties are key-value pairs, and the JMS message headers define the metadata for some messages. Peoperties is generally used to save some additional information. The body is used to hold data content.

Kimmking: In general, WS is synchronous, and JMS is asynchronous or synchronous.

Everyone: What is the relationship between RMI and the RPC in soap?

KIMMKING:RPC is remote process call

Kimmking:rmi is a kind of rpc,rpc itself without specification,

Kimmking: As long as the remote call is implemented, RPC

Kimmking: such as RMI net-remoting ws/soap/rest Hessian XMLRPC Thrift Potocolbuffer and so on.


KIMMKING:RPC has a common structure, which is the Serialization/deserialization+stub+skeleton

Forest Sen: So RPC is a remote call design thinking, emphasizing the transparent call to the remote method, which looks like a local call is cutting.

Everyone: Oh, that RPC emphasizes transparent remote method invocation, while Ms emphasizes common information exchange.


Kimmking: Positive solution. Interested can understand by themselves, Ps:dwr is also considered a standard RPC

Kimmking: Back to JMS.

KIMMKING:JMS defines the message format, we can consider how the message interacts.

Kimmking: Messages are not appearing out of thin air, so there must be a message producer for outgoing messages.

Everyone: What type of information do header,properties,body have in their main categories?

Kimmking:

Header and properties are key-value pairs.
Body is the specific content to be passed.
Headers are typically metadata for messages. I said it earlier.
Properties can be placed with some custom additional information.

Kimmking: The message needs to be produced by the producer. In the same way, the message needs to be delivered to the consumer who needs it.

Kimmking: Besides the news, we have two concepts, producers and consumers.

Everyone: Yes.

Kimmking: There's actually an implied thing, that's MQ.

Kimmking: or called JMS server

Kimmking: Producer-generated messages are typically sent to a JMS server, which is then passed to the consumer for processing by the server.

Everyone: the 3-point structure of JMS mentioned earlier is the producer, the consumer and the server.

Kimmking: Yes.

Kimmking: The message can be seen as an abstraction of the object, or an abstract concept.

Kimmking:server should be said to be used for staging or relay news.

Kimmking: Suppose there are multiple consumers, and if a message represents an object or an irreducible piece of data, then only one message will be available for each message.

Kimmking: We call this pattern point to point, PTP.

Sen: Why only one message can get to each message.

Kimmking: Just one piece of data cannot be repeated to two consumers.

Kimmking: For example I have an apple, you three people want, I can only give one person. One more apple, I can only give one person.

Kimmking: This man may not be the same person as the one in front of him.

Everyone: Take it and it's gone. Equivalent to only one instance of each message. Take it and it's gone.

Kimmking: Yes.

Kimmking: But if the message is something that can be copied or abstracted,

Kimmking: The situation is different.

Kimmking: For example, the message is a sentence: 6 mu classmate is a master of the girls.

6 Wood: .....

Kimmking: You all want to ask me 6 mu classmate's situation, I can tell you the news separately.

Everyone: That's the equivalent of multicasting. Meager kind.

Kimmking: We call this mode the publish subscription model.

Kimmking:publish/subscribe. Is that every release of Ali's message, can be shared by many individuals.

Kimmking: The sender of the message is called the publisher, the person who gets the message, the Subscriber.

Kimmking: After the message is sent out, you need to put it on a "place" on the server, where we call the destination destination

KIMMKING:PTP destination, we call it the queue.

Kimmking:pub/sub destination, we call topic.

Kimmking: Note that the JMS specification is very similar to the JDBC specification and is a simple client perspective and does not cover the concept and description of any server segment.

The relationship between KIMMKING:JMS and JMS server is equivalent to
The relationship between JDBC and database

Kimmking: In this sense, ACTIVEMQ is the equivalent of MySQL

Everyone: So ACTIVEMQ is a server that supports the JMS specification.

The KIMMKING:JMS specification itself does not have any detailed specifications for the server ~

Kimmking: So, it is mainly implemented an MQ, a small part of which is to implement the JMS specification, is how to use MQ, the equivalent of MySQL Java driver.

Kimmking: "ACTIVEMQ is a realization of JMS," this sentence is actually very unscientific.

KIMMKING:JMS also defines a selector, similar to the JS framework of Selector

Kimmking: You can define conditional filtering messages, whose syntax is a subset of SQL92.

KIMMKING:ACTIVEMQ, you can use XPath.

Everyone: XPath is not an XML thing. Isn't the message sent in an XML format? Heterogeneous systems do not use XML for anything.

Kimmking: Messages are abstract concepts that can be any format. Note that the JMS three letters equals the Java message service. are generally not in XML format.

Kimmking:xpath can be used not only in Xml.xpath, which is essentially a selector for tree-level data. Aside from the syntax weirdness, XPath and various El (Mvel\ognl\ ... ) almost

Everyone: the choice of the function is very powerful.

Kimmking: A generic JMS message is not an XML, but a Java object, and it is clear that JMS does not consider heterogeneous systems.

Kimmking: It doesn't even consider something that is not java. However, MQ has to solve the problem by itself.

KIMMKING:JMS is not defined to solve heterogeneous systems, but the realization of this basic JMS server (various MQ) solves heterogeneous problems after it matures.

Kimmking: With the database under each platform to achieve their own driving a truth.


KIMMKING:JMS by default, both send and receive messages are synchronized.

Kimmking: In other words, it's active.

Kimmking: Need our explicit send or receive

Kimmking: So, the specification defines a messagelistener that can handle messages passively when a message arrives (asynchronously).

Kimmking: In fact, there is a common scenario for message delivery

Kimmking: It's request/response mode.

Kimmking: Not only is sending out a message, I have to wait for a return response message.

Kimmking: What is the mechanism to know that the current message has been sent back.

KIMMKING:JMS is not defined to solve heterogeneous systems, but the realization of this basic JMS server (various MQ) solves heterogeneous problems after it matures.

Everyone: What happens when a message is sent back to respond with a failure.

Kimmking: Oh, you put forward a very meaningful question.

Kimmking: It is also the most important issue above all the concepts and functions that JMS considers.

Kimmking: It is not only that we have to deliver messages, but also to protect the reliability of the message.

Kimmking: Further, we want to ensure that message delivery is efficient and highly reliable.

Kimmking: So, JMS introduces two concepts, acknowledgements, and transactions.

Everyone: Like the database Ah ~

Kimmking:kimm not always take db for example.

Kimmking: The confirmed object is a message that can be automatically acknowledged when a message is received. You can also set up a manual transaction in one session, like JDBC, and after processing is completed, submit and confirm all messages.

Kimmking: Unfortunately, forwarding does not support transactions.

Kimmking: Taobao inside the MQ framework, to achieve the delivery of transactional.

Kimmking: The confirmation is that the consumer gets a message, how to not confirm, MQ will retry to send it to you again.

Kimmking: You can be as if you didn't sign the message. So, it's going to give you a replacement.

Kimmking: You mean that after receiving the information, the consumer sends a confirmation to the JMS server

KIMMKING:JMS server confiscated this confirmation and has been sending it for a certain amount of time.

Everyone: So how does the producer know that his message has been sent to success? Or the recipient has successfully received it.

Kimmking: Producers don't know. Producers and consumers are transparent. They don't know each other's existence.

Everyone: The producer does not need a JMS server to send him a confirmation message. This is to know that his message has been really sent out AH. Otherwise lost in the middle how to do.

Kimmking: In fact, there are also confirmed. The equivalent of the post office, but how the post office to lose your letter, you still have a way to wood. The implicit assumption is that once the message is sent, we completely trust the Post office.

Kimmking: We believe MQ is reliable.

Kimmking:mq told us that we sent success, MQ internal things, producers are invisible, how can we believe that consumers will be able to receive it.

Kimmking: We know that the person who receives our mail is not signed, the message will be sent back, or it may be repeated in the consumer department.

Kimmking: But, producers do not know this process, send this head without this reliability of processing, how to do it.

Kimmking: And if MQ is irresponsible, put the message in memory, after MQ crashes, the message is lost.

Kimmking: So, the JMS specification defines the persistence of messages.

Kimmking: The message is divided into two kinds, one is strict can not be lost message, one is the occasional loss of the message.

Kimmking: The former performance is significantly slower than the latter, because the latter can be completely in memory processing, the system crashes when the memory of the message will be lost.

Kimmking: The former requires MQ to be persisted, and a single, persistent medium is placed in it.

Kimmking: Then MQ tells the news producer that I have received the message you sent, you rest assured.

Kimmking: This is obviously slower than the message that is not persisted.

Kimmking: When the message is consumed by the consumer, MQ removes the message from the media.

Kimmking: It does not matter when the system crashes, resuming messages from the media after reboot.

Kimmking:queue is persisted by default.

Kimmking:topic, because the default is non-persistent to send to more than one person.

Kimmking: That means the messages in the topic are in memory and sent only to subscribers online.

Kimmking: What if you want to get all the messages in topic (like LDAP, give me the data after the last sync)

Kimmking: At this point, there is a new concept, persistent subscription.


Kimmking: As you can imagine, you received 1th, 2, 3 data during your online period. You're off the line. During the online period, the system has more than 4th, 5 data, sent to all Subscribers, deleted.
You are online again ... You want 4th, 5 data after the last data you fetched

Kimmking: This is a tricky place in MQ.

Kimmking: The principle is to persist the Subscriber and topic messages at the same time.

TICMY: I am a persistent subscription after a long time not online, I whole. I haven't been online for years. How many messages should I keep? I'm not on the line, I'm wasting all the storage space on the server.


Kimmking: It's possible. This is one of the reasons why persistent subscriptions are not commonly used.

Kimmking: Persistent Subscriptions Another problem is that after you get disconnected, connect to the JMS server,server how do you know you are the one you used to be?

Everyone: According to KK above, this send directly there is a session state to receive information Oh ~

Kimmking: With the HTTP SessionID a truth. Every time you come, you use one of the same clientid.

KIMMKING:MQ the persistent subscriber's information to the local, and when it is not online, it is also treated as a subscriber and the message sent to it is persisted to storage. After this message is confirmed by all persistent subscribers, it is deleted.

Kimmking: So MQ also needs to persist the confirmed data. For topic with a persistent subscription, there may be some persistent subscribers coming online to get the data and confirm that some of the logs are confirmed.

Kimmking: The principle of reliability is to repeat a lot of the hair, save the persistence of security, the data will not be discarded.

Kimmking: Reliability is inherently conflict with high availability.

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.