MQ is calledMessage Queue, Message Queuing (MQ) is an application-to-application communication method.Applications communicate by writing and retrieving queued application-specific data (messages) without requiring a dedicated connection to link them. Messaging refers to programs that communicate by sending data in messages, rather than communicating with each other by directly calling each other, which is usually used for techniques such as remote procedure calls. Queuing refers to applications communicating through the queue. The use of queues removes the need for the receiving and sending applications to execute simultaneously. Among the more mature MQ products areIBM WEBSPHERE MQ。
A typical representative of the MQ consumer-producer model, One end continuously writes messages to the message queue, while the other end can read or subscribe to the messages in the queue. MQ is similar to JMS, but the difference is that JMS is a standard and API definition for SUN JAVA message middleware services, and MQ is a specific implementation and product that follows the AMQP protocol.
In the project, some time-consuming operations that do not require immediate return are extracted and processed asynchronously, and this asynchronous processing method greatly saves the server's request response time, thereby improving the system throughput.
JMS as Java Message Service (Java Message Service) The application program interface is an API for message-oriented middleware (MOM) in the Java platform. It is used to send messages between two applications or in a distributed system for asynchronous communication. Java Message Service is an API that has nothing to do with specific platforms. Most MOM providers support JMS.
JMS(Java Messaging Service) Is a technical specification for message-oriented middleware (MOM) on the Java platform, which facilitates the exchange of messages by Java applications in the messaging system, and simplifies the development and translation of enterprise applications by providing standard interfaces for generating, sending, and receiving messages. Serve for Java messages.
JMS is a vendor-independent API used to access messaging system messages. It is similar to JDBC(Java DatabaseConnectivity): Here, JDBC is an API that can be used to access many different relational databases, and JMS provides the same vendor-independent access method to access messaging services. Many manufacturers currently supportJMS, IncludingIBM of MQSeries, BEAWeblogic JMS service and Progress's SonicMQ, these are just a few examples. JMS enables you to send messages from one JMS client to another through messaging services (sometimes called message brokers or routers). Message is a type of object in JMS, byTwo partscomposition:Header and message body. The header consists of routing information and metadata about the message. The message body carries the data or payload of the application. According to the type of payload, the message can be divided intoSeveral types, They carry: simple text (TextMessage), serializable objects (ObjectMessage), attribute collection (MapMessage), byte stream (BytesMessage), raw value stream (StreamMessage), and messages with no payload (Message)。
JMS is a technical specification for providing message services. It establishes all data structures and interaction processes in the entire process of providing message services. And MQ is a message queue service, which is message-oriented middleware (MOM) The final realization is a real service provider;MQThe implementation can be based on JMS or other specifications or standards.
The most currently selected isActiveMQ。ActiveMQYesApacheProduced, the most popular and powerful open source message bus.ActiveMQIs a full support for JMS1.1 and J2EE 1.4 specificationsJMS ProviderAchieve, althoughJMSIt has been a long time since the specification was introduced, butJMSIn today'sJ2EEThe application still plays a special role in the middle.
Java, C, C++, C#, Ruby, Perl, Python, PHP. Application Agreement:OpenWire,Stomp REST,WSNotification,XMPP,AMQPeronimo,JBoss 4, GlassFish,WebLogic) Test, which passedJCA 1.5 resource adaptorsThe configuration allows ActiveMQ to be automatically deployed on any J2EE 1.4 compatible commercial serverin-VM,TCP,SSL,NIO,UDP,JGroups,JXTAActiveMQ middleware is written in Java language, so it naturally provides Java client API. But ActiveMQ also provides clients for C/C++, .NET, Perl, PHP, Python, Ruby and some other languages. When you consider how to integrate different platforms and write applications in different languages, ActiveMQ has great advantages. In such an example, multiple client APIs are possible to send and receive messages through ActiveMQ, regardless of the language used. In addition, ActiveMQ also provides a cross-language function that integrates this function without using remote procedure call (RPC) is indeed an advantage, because the message assists application decoupling.
Applications that use RPC synchronous calls are very common. Assume that most client-server applications use RPC, includingATM,mostWEBApplications, credit card systems, point of sale systems, etc. Although many systems are very successful, the conversion to use asynchronous messages can bring many benefits, and will not give up the response guarantee. The system that uses synchronous requests has a large limit in size, because the request will be blocked, which causes the entire system to slow down. If you use asynchronous message substitution, you can easily add additional message recipients, so that messages can be consumed concurrently, thereby speeding up request processing. Of course, your system applications should be decoupled.
As discussed earlier, tightly coupled architectures can cause many problems, especially if they are distributed. The loosely coupled architecture, on the other hand, has proven to have fewer dependencies and can better handle unforeseen changes. Not only can components be changed in the system without affecting the entire system, but component interaction is also quite simple. Compared with a synchronous system (the caller must wait for the callee to return information), an asynchronous system (the caller does not care after sending the message, ie fire-and-forget) Can bring us event-driven architecture (event-driven architecture EDA`)。
A decoupled, asynchronous architecture system allows the agent to configure more clients, memory, etc. (that is, vertical scalability) to expand the system, rather than adding more agents (that is, horizontal scalability). Consider a busy e-commerce system like Amazon. When a user buys an item, in fact the system needs many steps to process, including placing an order, creating an invoice, paying, executing an order, shipping, etc. However, after the user places an order, he will immediately return to the "Thank you for placing an order" interface. Not only is there no delay, but users will also receive an email indicating that the order has been received. The example of placing an order on Amazon is an example of multi-step processing. Each step is handled by a separate service. When the user places an order, there is a synchronized form submission action, but the entire processing flow is not synchronized through the browser. On the contrary, the order is immediately accepted and feedback. The remaining steps are handled asynchronously. If an error occurs during processing, the user will be notified by email. Such asynchronous processing can provide high load and high availability.
Many systems using event-driven design are designed to achieve high scalability, such as e-commerce, government, manufacturing, and online games. Separating commercial processing steps through asynchronous messages to various applications can bring many possibilities. Consider designing an application to complete a special task. This is the service-oriented architecture (service-oriented architecture SOA). Each service performs one function and only one function. Applications are combined through services, using asynchronous messages and eventual consistency between services. Such a design can introduce a complex event processing concept (complex event processing CEP). Using CEP, interactions between components can be recorded and tracked. In an asynchronous messaging system, it is easy to add a layer of processing between components.
What is activeMQ?
Is a message bus under the Apache company
ActiveMQ is an open source compatible Java Message Service (JMS) 1.1 message-oriented middleware room. From the Apache Software Foundation. ActiveMQ provides a loosely coupled application architecture.
What can activeMQ do?
Used for asynchronous communication between services
activeMQ advantage
1. Traffic Xiao Feng
2. Tasks are processed asynchronously
Features: can be decoupled
(three elements of learning new technology: what? What can you do? What are the advantages?)
figure 1:

Communication mode:
2. Publish/subscribe model (topic)
Detailed explanation: The principle of this feature is like this, in activeMQ
== Note: The message is pushed and pulled (message production and consumption), not the mq server to actively send ==
Detailed explanation: The most classic is that when the user registers, we need to use activeMQ as the middleware. After the user registers, we send the user's mailbox number and verification code and other information to the activeMQ message queue through the activeMQ production end In the message queue, once the data appears in the message queue, our mail module can obtain this data through the consumer by monitoring the activeMQ message queue in real time, and the mail module will parse the data and send it to the user. mail
Detailed explanation: The principle is the same as sending email
Detailed explanation: In order to ease the pressure on the database, we put the frequently called data into the index library. When there is a request to query, we will first query the index library. If there is data in the index library, then we do not need to query the database , Which can greatly reduce the pressure on the server, but a problem that comes with it is that if the data in our server has changed, and when browsing users querying data, because there is already data in the index library, then this Once the data in the database and the index library are inconsistent, how to solve this problem? We thought of using activeMQ to monitor the operation of the database to synchronize the data of the database and the index library. When the background administrator or real estate agent performed additions, deletions and changes to the database data, we monitored the data changes through activeMQ. Get the id of the modified data, and then use the id of the data in another service module to query the database first, and then judge according to the query result, and then do the data synchronization of the index database. For example, if the query result returns empty, it means that the product has been deleted, then we can delete the data in the index library according to the id of the data.
4. Synchronize static pages
Detailed explanation: This principle is the same as the previous synchronous index library. The purpose is to alleviate the pressure on the server. We have found through data analysis that the data on some of our product detail pages are actually the same and can be passed.freemarkerThe page static module plus the data queried from the background is assembled into a static page, and where does this data come from? After discussion and research, we finally agreed that it is better to put it in the buffer, so that the pressure on the database can be greatly reduced, and the other benefit is thatSince the page is purely static, So the data on the page is dead data, so that there is no need to have a lot of data interaction with the back-end database like JSP dynamic pages, which can minimize the pressure on the server. In fact, this technology has been used by many large companies. For example, Taobao, JD.com, NetEase, etc., if we are careful, we will find that their pages are actually static pages in HTML format.
ActiveMQ installation:
ActiveMQ installation is very simple, just download it from its official website to the linux environment, unzip and enter the bin directory
|
Just use the start command to run. Then we open the browser to enter the management backgroundhttp://localhost:8161/admin/
Enter the default account password:admin. You can see the control console.
ActiveMQ uses the jetty server, open the conf/jetty.xml file and find
|
willproperty nameforauthenticateAttribute ofvalue="false"To"true",
The login username and password of the console are saved inconf/jetty-realm.propertiesIn the file, the content is as follows:
|
It is worth noting that the format of the username and password is
User name: password, role name
1. Introduction to JMS Full name: Java Message Service Chinese: Java Message Service. JMS is a set of Java API standards. The original purpose is to enable applications to acce...
ActiveMQ introduction ActiveMQ is the most popular and powerful open source message bus produced by Apache. ActiveMQ is a JMS Provider implementation that fully supports the JMS1.1 and J2EE 1.4 specif...
Foreword: Recently I came into contact with the message queue and learned about activeMQ, and I made a simple record here to facilitate future queries. 1. What is ActiveMQ 1.1 Introduction ActiveMQ is...
What is ActiveMQ MQ, commonly known as message queue, also known as message middleware, is a medium through which applications can deliver messages in a distributed system.ActiveMQ,RabbitMQ,kafka。Acti...
Introduction to JMS Full name: Java Message Service Chinese: Java Message Service. JMS is a set of Java API standards. The original purpose is to enable applications to access the existing...
1. Message middleware 2.MQ 3. ActiveMQ feature list 4. When to use ActiveMQ 5. Download ActiveMQ 6. Unzip 7. Start ActiveMQ 8. Web console access ActiveMQ 1. Message middleware Message Orient Middlewa...
1. Resource preparation 1.1 environment Centos7、jdk8、activemq5.15.8 1.2 ActiveMQ5.15.8 Installation package Official website download address:http://activemq.apache.org/activemq-5158-release.html The ...
ActiveMQ installation configuration and use ActiveMQ Introduction ActiveMQ is the most popular and powerful open source messaging bus from Apache. ActiveMQ is a JMS Provider implementation that fully ...
ActiveMQ installation configuration 3-extracting installation files tar -zxf apache-activemq-5.9.0-bin.tar.gz 4 check permissions ls -al apache-activemq-5.9.0/bin if the permissions, you can not perfo...
[url = http: //activemq.apache.org/download.html] [b] activeMQ Download [/ b] [/ url] [Url = http: //activemq.apache.org/download-archives.html] [b] activeMQ old version Download [/ b] [/ url] [B] [co...