ActiveMQ Notes (a) Overview of the mounting

I. Background messaging middleware

1. Introduction: Consider the use of messaging middleware scene?

  •   It requires the use of messaging middleware scenario in which
  •   Why should the introduction of messaging middleware in the system

2, according to the above mentioned problems: from life to actual production Case Case

Service-based micro-architecture Background: chained calls to our general process of writing program time, in order to complete a whole function will split it into multiple functions (or sub-modules), such as module A calls Module B, Module B calls module C, C module calls module D. But in large-scale distributed applications, RPC interaction between complex systems, a function to be called back hundreds of interfaces is not impossible, the transition from stand-alone micro-architecture to the general rule distributed services architecture.
Note meaning: these architectures will be considered at this point what the problem?

Direct calls between landing system actually works and problems:

  • Interface is coupled between the system more serious
  • The face of large concurrent flow, easy to be washed away
  • Waiting for sync performance issues

Coupling the interface between (1) the system is more serious

每新增一个下游功能,都要对上游的相关接口进行改造;

For example: if the data to be transmitted to the system A and system B System C, there may be transmitted to the difference data for each system, so the system A the data to be transmitted to each system have been assembled, and then transmitted one by one;
when the code is on-line and then added a demand:
the data is also sent to D, a D on new system also accepts data a system, then you need to modify a system that allows him to perceive the presence of D system, while data deal to give D. In this process, you will see that each access a downstream system, the system must be A code reform, inefficient development of the FBI. Its overall structure below

        

(2) the face of large concurrent flow, easy to be washed away

每个接口模块的吞吐能力是有限的,这个上限能力如果是堤坝,当大流量(洪水)来临时,容易被冲垮。

For example spike business:
upstream operating system to initiate purchase orders, I was operating under a single
downstream spike system complete business logic
(read orders, check inventory, inventory freeze, balance check, balance freezing order, the balance of deductions, inventory reduction, generating water balance thaw, stock thaw)

(3) wait for the synchronization performance issues

RPC接口上基本都是同步调用,整体的服务性能遵循“木桶理论”,即整体系统的耗时取决于链路中最慢的那个接口。

For example, A calls B / C / D is 50ms, but this time B calls the B1, take 2000ms, then directly drag on overall service performance.

       

3. Solution:

In designing the system can clear targets to be achieved:

(1)要做到系统解耦,当新的模块接进来时,可以做到代码改动最小;能够解耦

(2)设置流量缓冲池,可以让后端系统按照自身吞吐能力进行消费,不被冲垮;能削峰

(3)强弱依赖梳理能将非关键调用链路的操作异步化并提升整体系统的吞吐能力;能够异步

Second, an overview of the messaging middleware

1. Definitions

Message-oriented middleware (message-oriented middleware) MOM can solve the above problems, it refers to the exchange of data with efficient and reliable messaging platform-independent mechanism, and distributed to the integrated communication system based on the data.
By providing a transfer message and message queuing model provides decoupling applications in a distributed environment, elastically stretchable, redundant storage, flow clipping, asynchronous communication, data synchronization.

Process messaging: the sender to send the message to the message server, message server messages stored in a number of queue / topic in the topic, at the right time, back to the message server forwards the message to the recipient. In this process, sending and receiving is asynchronous, that is, send no waiting, and the sender and receiver of the life cycle is not necessarily related; in particular, publish pub / subscribe under sub mode, you can also complete many of communication, that allows a message has multiple recipients.

          

2. Features

主要特点有两个: ①采用异步处理模式、②使用应用系统之间解耦合

(1) asynchronous processing mode

Message sender can send a message without waiting for the response. Message sender to send a message to a virtual channel (topic or queue) on;
the message recipient is subscribed or love listening to the channel. A message may eventually forwarded to one or more of the message recipient, the recipient of these messages are synchronized without having to make a response to the message sender. The entire process is asynchronous.

Case: In other words, when communication between a system with another system, if the system A wants to send a message to System B, let him to deal with. A system but the system does not care about how to handle or B in the end there is no deal, so the system A to send a message to MQ, then regardless of "life and death of" this message, then the system B MQ consumption from the inside out process can be. As for how to deal with, whether processed, when processing, system B thing is, regardless of the system A.

               

Decoupling between (2) applications

  • The sender and receiver do not have to understand each other, just make sure the message
  • The sender and receiver need not be online at the same time

3, the overall architecture:

             

4, the message middleware function:

    解决了耦合调用、异步模型、抵御洪峰流量,保护了主业务,消峰。

5, download and use the related functions

(1) download:

ActiveMQ official website: http://activemq.apache.org/

           

(2) main functions:

实现高可用,高性能,可伸缩,易用和安全的企业级面向消息服务的系统

(3) use:

  • Consumption and handling asynchronous messages
  • Consumer sequence control message
  • Spring can be integrated to simplify the code or SpringBoot
  • MQ cluster configuration fault-tolerant cluster

Three, Activemq download and install

1, the official website to download 

http://activemq.apache.org/

2, linux installation

Upload: Use rz and sz commands upload and download

  • / Opt directory
  • Unzip apache-activemq-5.15.9-bin
  • In the root directory mkdir / myactiveMQ
  • cp -r apache-activemq-5.15.9 /myactiveMQ/
  • Normal start mq: ./activemq start
  • actvemq the default process port is 61616
  • View background processes methods:
  ps -ef | grep activemq | grep -v grep    // grep -v  grep 可以不让显示grep 本来的信息
  netstat -anp | grep 61616     // activemq 的默认后台端口是61616
  lsof -i:61616

3, start:

(1) Normal startup  default port is 61616

       

关闭:  ./activemq stop

(2) with a running log of the start-up mode

Let's not start the console log information print, and put a special file:

./activemq start >  /myactivemq/myrunmq.log

4, Apache ActiveMQ Console

        http://127.0.0.1:8161/admin

默认的用户名和密码是admin/admin  

        

5, notes:

  • 61616 using ActiveMQ JMS port to provide services
  • ActiveMQ using port 8161 to provide management console service

Guess you like

Origin www.cnblogs.com/wushaopei/p/12288607.html
Recommended