search
Homephp教程PHP开发Related understanding of Session settings in ActiveMQ

Reference blog post: http://www.cnblogs.com/SzeCheng/p/4792084.html

Reference blog post: http://activemq.apache.org/producer-flow-control.html

Explanation of terms:

P: Producer

C: Consumer

Server: P or ActiveMQ service

Client: ActiveMQ service or C

The sign that the client successfully receives a message is that the message has been signed. Successfully receiving a message generally includes the following three stages:

1. The client receives the message;

2. The client processes the message;

3. The message is signed.

session = connection.createSession(Boolean.false, Session.CLIENT_ACKNOWLEDGE);##第一个参数控制事务,第二个参数控制消息

In a Session without transactions, when and how a message is signed depends on the Session settings.

1. Session.AUTO_ACKNOWLEDGE

When the client returns successfully from receive or onMessage, Session automatically signs the client's receipt of this message.

2. Session.CLIENT_ACKNOWLEDGE

The client signs the message by calling the acknowledge method of the message.

message.acknowledge();

In a Session with a transaction, the signature automatically occurs when the transaction is submitted. If the transaction is rolled back, all received messages will be delivered again. In fact, Session.CLIENT_ACKNOWLEDGE here is of little use.

session = connection.createSession(Boolean.TRUE, Session.CLIENT_ACKNOWLEDGE);
session.commit();

Summary:

1. For the producer: the server is P and the client is ActiveMQ service. Session is set to AUTO_ACKNOWLEDGE and CLIENT_ACKNOWLEDGE. Relatively speaking, the difference is not very big. It depends on the situation.

2. For consumers: the server is ActiveMQ and the client is C. The Session is set to AUTO_ACKNOWLEDGE. When a message is received (receive or onMessage returns successfully), the consumption is successful, and the data is removed from the queue. We don't care whether the data is correctly processed into the results we want; when the Session is set to CLIENT_ACKNOWLEDGE, the acknowledge method must be manually called for successful consumption, and then the data is removed from the queue.

3. Which mode the Sessions of P and C are set to have no influence on each other.


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor