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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



1. Choose the appropriate client transport protocol ActiveMQ supports a variety of client transport protocols, including STOMP, AMQP and OpenWire. Choose the right protocol based on your application needs to optimize performance and reliability. 2. Configure message persistence. Persistent messages are persisted even after server restarts, while non-persistent messages are not. For critical messages, choose persistence to ensure reliable delivery. Demo code: //Set message persistence MessageProducerproducer=session.createProducer(destination);producer.setDeliveryMode(Deliv

1. Message routing uses JMSSelectors to filter messages: Use JMSSelectors to filter incoming messages based on message attributes and only process relevant messages. Create a custom message router: Extend ActiveMQ's routing capabilities to send messages to specific destinations by writing a custom router. Configure polling load balancing: evenly distribute incoming messages to multiple message consumers to improve processing capabilities. 2. Persistence enables persistent sessions: ensuring that even if the application or server fails, messages can be stored persistently to avoid loss. Configure the Dead Letter Queue (DLQ): Move messages that fail to be processed to the DLQ for reprocessing or analysis. Using Journal Storage: Improve performance of persistent messages, reduce

ActiveMQ is an open source message middleware produced by Apache. It is developed using Java language and has the characteristics of reliable messaging, asynchronous communication and cluster support. ActiveMQ can exchange data between different applications and supports multiple messaging protocols, such as JMS, AMQP and MQtT. 1. Advantages of ActiveMQ ActiveMQ is a very mature message middleware. It has the following advantages: Reliable message delivery: ActiveMQ can guarantee reliable delivery of messages. Even in the case of network failure or server downtime, the message will not be lost. lost. Asynchronous communication: ActiveMQ supports asynchronous communication, allowing non-real-time communication between different applications.

目录结构引入maven依赖org.springframework.bootspring-boot-starter-parent1.5.4.RELEASEUTF-8UTF-81.8org.springframework.bootspring-boot-starterorg.springframework.bootspring-boot-starter-weborg.springframework.bootspring-boot-starter-testtestorg.springframework

1. Message Broker is the core component of ActiveMQ and is responsible for processing all message flows. It provides a platform where applications can connect, send and receive messages. BrokerServicebroker=newBrokerService();broker.addConnector("tcp://0.0.0.0:61616");broker.start();2. The message queue is a logical concept container for storing messages in ActiveMQ. A message queue can receive messages from multiple producers and deliver them to multiple consumers. Queuequeue=session.createQueue("my

1Import the dependencies required for integration: org.springframework.bootspring-boot-starter-activemq2Create the application.properties file spring.activemq.broker-url=tcp://127.0.0.1:61616spring.activemq.user=adminspring.activemq. password=adminserver.port=8080queue=myqueue3. Custom configuration file QueueConfig reads the configuration file

1. Introduction to JavaJMS JavaJMS is a Java API used to create, send and receive messages. It provides reliable messaging capabilities and is ideal for distributed systems and enterprise-level applications. Messaging systems can send messages from one application to another, even if the two applications are on different machines. 2.JMSAPIJMSAPI defines a series of interfaces and classes for sending and receiving messages. These interfaces and classes include: javax.jms.ConnectionFactory: used to create connections to JMS servers. javax.jms.Connection: Connection to the JMS server. javax.

ActiveMQ is a completely open source Java message server and one of the most popular projects of the Apache Software Foundation. It follows the Java Message Service (JMS) specification and provides a set of APIs for building distributed, asynchronous and message-oriented applications. ActiveMQ is known for its reliability, efficiency, and flexibility, making it ideal for a variety of enterprise applications. Reliability: ActiveMQ uses a persistent storage mechanism to ensure reliable delivery of messages. When a message is sent to ActiveMQ, it is written to disk and even if the server fails, these messages will not be lost. When the server restarts, it restores these messages from the persistent store and passes them
