Joke Collection Website - Public benefit messages - What is ActiveMQ and what is it used for?

What is ActiveMQ and what is it used for?

1. The ActiviMq message queue solves the problem of service decoupling and alleviates the situation where the server cannot handle the large concurrency of the service. (kafka, rabbitMQ, activiMQ)

Other functions: asynchronous processing, message communication, traffic peak reduction, application decoupling

Application scenarios:

1. User When registering, the key point is to save user information in the database. Sending text messages for verification or sending emails increases the complexity of the business. At this time, using MQ, sending text messages and sending emails to notify MQ will be completed by another service platform.

2. Search platform and caching platform

Query data, establish cache and index, do not query from the database, query from the cache or index library, when the database is added, modified or deleted When a message is sent to MQ, the cache platform or index platform obtains the message from MQ and updates the cache or index.

ActiveMQ uses the standard producer (completes the production of messages and sends messages) and consumers (obtains messages and completes its own business logic) model

There are two data structures

Topic (publish and subscribe) One producer corresponds to multiple consumers. Messages are not persisted by default and persistence needs to be configured manually. If server A hangs up and another message is produced, it will be used by server B. Even if it is restarted, server A will no longer get the message

Product system, inventory system, generate product details page system, now you want to add a product information, the information must be known to the inventory system and the product information details page system.

Queue (point-to-point), one producer corresponds to one consumer, default message persistence

StringMessage

mapMessage

byteMessage

objectMessage

To complete message persistence in topic mode, it is necessary to ensure that each consumer has a unique clientID (this article is from Beida Jade Bird)