Overview of Java Message middleware and JMS specification

Source: Internet
Author: User
Tags rabbitmq

Why you need to use message middleware

Before we introduce the message middleware, let's look at a story:

The bedtime Story of Lao Wang:

In a long long time ago, Xiao Ming next to a neighbor surnamed Wang, let's call the old king next door. Next door Lao Wang has a big daughter, named Wanglanhua beautiful, beautiful childhood love to listen to the old Wang told bedtime stories, every night before falling asleep before the old Wang told bedtime stories to sleep. But one day beauty to the field to go to college, Lao Wang in order to be able to tell the story of beauty, can only be done by telephone way, as follows:

But sometimes because of the beautiful phone signal is not good or no electricity, and so on, leading to the old Wang can only keep the contact until the telephone to get through. Lao Wang Heart: What can I do, I am also very desperate ah. Although the beauty may be late to hear the story, but the process is not very difficult. Until one day, Lao Wang's second daughter Wanglanhua to go to school, solo show also love to listen to the old Wang told bedtime stories. Lao Wang has no way, can only give the solo show to call. But this will lead to a single show waiting for a long time to wait for the phone, because the old Wang had to give the beauty of the first show to tell. Sometimes it is more troublesome to encounter a bad signal, so that every day needs to be very late, Lao Wang also feel that the body seems to be hollowed out:

After a few nights, Lao Wang thought every day like this can't ah, make a body day than a day. So as the old programmer's old Wang pondering, think of a similar message middleware approach, that is to register a public number. Lao Wang just need to put the daily bedtime story into the public number, let two daughters to subscribe to the public number on the line. Then two daughters not only can not wait for who listens to the story first, the old king also does not have to stay up every day, and everybody thinks this public number tells the story is very good, therefore listens to the old Wang to tell the story the person more and more, from then on the old king walks the peak of life, really can be very exciting:

With the help of the general number of the story, Lao Wang does not need to care about how many people want to listen to the story, Lao Wang just need to put the story into the public number. People who want to listen to a story only need to have a network to subscribe to the public number, so that not only readers can listen to the story anywhere, and Lao Wang does not need to be told stories and spend too much time. This story is the interpretation of the message middleware for us to solve some of the problems.

Let's raise a chestnut, for example we now have a login system. We achieve is through the SMS verification code to sign in, so when the user log in the system needs to call the SMS service to send SMS verification code to the user. In addition to the SMS service, there is also a point service to load the user's points information. Logging is also required when a user logs on, and a log service needs to be called. As the system progresses, the number of services that need to be invoked at logon is likely to increase. Then it means that the user to do a simple login operation, you need to wait for a variety of service calls completed before logging on, so that the time to log on to become more and more long, in case there is a service stuck in the user's login will also be stuck, so the login system and related services coupling is very high, Causing the user to log on only takes a lot of time that is not relevant to the login feature itself. This is where other system-aware events occur through service invocation:

Message middleware is used to remove this coupling, when the user sends a login request and through authentication, the message middleware can immediately notify the user login success, while the delivery of messages to other services by the message middleware to complete, that is, an asynchronous processing, and the user is not aware of, will not slow down the user's logon time. Decoupling service invocation via message middleware:

Benefits of Message Middleware:

    • Decoupling system
    • Asynchronous notification
    • Horizontal Scaling
    • Safe and reliable
    • Order Guarantee
    • ...
Message Middleware Overview

What is middleware:

    • Non-underlying operating system software, non-business application software, not directly to the end user, not directly to the customer value of the software collectively referred to as middleware.

What is message middleware:

    • Focus on sending and receiving data and integrating distributed systems with efficient and reliable asynchronous message delivery mechanisms

Message Middleware Flowchart:

Speaking of message middleware has to mention the JMS specification, what is the JMS specification:

    • The Java Message Service, or JMS, is a Java platform for message-oriented middleware APIs for sending messages between two applications, or distributed systems, for asynchronous communication.

Similarly, the messaging middleware also needs to have a certain understanding of the AMQP protocol and what is the AMQP protocol:

    • AMQP (Advanced Message Queuing Protocol) is an application-layer standard protocol that provides unified messaging services, and client-to-message middleware based on this protocol can deliver messages that are not subject to the limitations of different client/middleware products and different development language conditions.

JMS and AMQP Comparisons:

Common Message Middleware Comparison:

name Description features
ActiveMQ ActiveMQ is the most popular and powerful open source messaging bus that Apache has produced. ActiveMQ is a JMS provider implementation that fully supports the JMS1.1 and the Java EE 1.4 specification, although the JMS specification has been around for a long time, but JMS still plays a special role in today's Java EE applications. Multiple languages and protocols for writing clients. Languages: Java, C + +, C #, Ruby, Perl, Python, PHP. Application protocols: Openwire, Stomp, REST, WS, Notification, XMPP, AMQP. fully supports the JMS1.1 and the Java EE 1.4 specification (persistence, XA messages, transactions). Support for virtual themes, combination purposes, mirror queues, and more
RabbitMQ The RABBITMQ is an open-source AMQP implementation that is written in Erlang language by the server. Used to store forwarded messages in distributed systems, with good performance in terms of ease of use, scalability, and high availability supports a variety of clients such as Python, Ruby,. NET, Java, JMS, C, PHP, ActionScript. Is the complete implementation of the AMQP model (Vhost, Exchange, Binding, Routing Key, and so on). Support for features such as transactional and release confirmations to persist messages
Kafka Kafka is a distributed, partitioned and reliable distributed log storage service, which is a kind of high throughput distribution and subscription message system. It provides the functionality of a messaging system through a unique design Provides persistence of messages through the O (1) Complexity of disk data structures, which can maintain long-term stability even with terabytes of message storage. High throughput: Even very common hardware Kafka can support millions of messages per second.

Comprehensive Evaluation:

Jms

JMS Related concepts:

    • Provider: A messaging middleware server that implements the JMS specification
    • Client: An application that sends or receives messages
    • Producer/Publisher: Create a client that sends messages
    • Consumer/Subscriber: The client that receives and processes the message
    • Message: Data content passed between applications
    • Message patterns: The way messages are passed between clients, topic and queue patterns are defined in JMS

JMS Message mode:

Queue mode:

    • Clients include producers and consumers
    • Messages in the queue can only be consumed by one consumer
    • Consumers can consume messages in the queue at any time

Queue mode:

Theme mode:

    • Clients include publishers and Subscribers
    • Messages in the topic are consumed by all subscribers
    • Messages sent to a topic before consumers can consume subscriptions

Theme mode:

JMS encoded Interface:

    • ConnectionFactory Connection factory for creating connection factory objects connected to message middleware
    • Connection connection that represents the communication link between the application and the server
    • Destination destinations, specifying where messages are published and received, including queues or topics
    • Session sessions, which represent a single thread context for sending and receiving messages
    • Messageconsumer message Consumer, created by session, to receive messages sent to the destination
    • MessageProducer message producer, created by session, used to send messages to target
    • The message body, which is an object transmitted between the consumer and the producer, is typically composed of a message header, a set of message properties, and a message body

Relationships between JMS-encoded interfaces:

Overview of Java Message middleware and JMS specification

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.