ActiveMQ little knowledge: basic usage explanation

Introduction: ActiveMQ is an open source project developed in the Java language under Apache. It is an implementation of a message middleware based on the JMS (Java Message Servie) specification. It supports transactions and loads, and can be easily integrated with spring. The reason for using ActiveMQ is to achieve decoupling of system services, push asynchronous messages, increase system concurrency, and improve user experience. For example, I use it in my work and use it in time-consuming and asynchronous remote unlocking operations.

Two message methods:

Point-to-point method (PTP): A consumer corresponds to a producer, and the message produced by the producer can only be consumed by the designated consumer.

Publish/Subscribe Mode (Publish/Sub): After a producer generates a message and sends it, it can be received by multiple consumers. The message produced by the producer will not be persisted to the activemq server before being consumed by the consumer, and the message sent will automatically disappear. So when testing, you need to create a consumer object first, and then send a message to prevent message loss.

Differences: The two methods are similar, but the PTP method of message delivery: After the message producer sends it, the message will be persisted on the activemq server. If the message is consumed by the consumer, the message will be persisted on the server at the same time been deleted.
Publish and subscribe message delivery method: After the message producer sends the message, if there is no consumer to consume it, the message will not be persisted in the activemq client and will disappear immediately. If the created message is consumed, the activemq server will display the related content of the message.

Set the delay of sending messages

According to the needs of the project, you can set the delayed sending of the message
(1) First enter the conf directory under the installation directory of activemq

(2) Edit activemq.xml and set it as the delayed sending mechanism
Insert picture description herespring integrated activeMQ: https://blog.csdn.net/weixin_43945983/article/details/85097365

Guess you like

Origin blog.csdn.net/weixin_43945983/article/details/108128920