Home php教程 PHP开发 Related understanding of Session settings in ActiveMQ

Related understanding of Session settings in ActiveMQ

Nov 22, 2016 pm 01:14 PM
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);##第一个参数控制事务,第二个参数控制消息
Copy after login

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);
Copy after login
session.commit();
Copy after login

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 of this Website
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 Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

20 Best Practices for Java ActiveMQ 20 Best Practices for Java ActiveMQ Feb 20, 2024 pm 09:48 PM

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

20 Advanced Tips for Java ActiveMQ 20 Advanced Tips for Java ActiveMQ Feb 20, 2024 pm 09:51 PM

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

Java ActiveMQ: Easily implement asynchronous communication in distributed systems Java ActiveMQ: Easily implement asynchronous communication in distributed systems Feb 19, 2024 pm 10:18 PM

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.

How to integrate ActiveMQ in SpringBoot How to integrate ActiveMQ in SpringBoot May 11, 2023 pm 06:16 PM

目录结构引入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

20 must-know concepts for Java ActiveMQ 20 must-know concepts for Java ActiveMQ Feb 21, 2024 am 08:40 AM

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

How to integrate Activemq in Springboot How to integrate Activemq in Springboot May 21, 2023 pm 01:13 PM

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

Getting Started with Java JMS: Master the Basics of Messaging Technology Easily Getting Started with Java JMS: Master the Basics of Messaging Technology Easily Feb 26, 2024 am 10:34 AM

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.

Java ActiveMQ: Helping enterprises achieve reliable and efficient message transmission Java ActiveMQ: Helping enterprises achieve reliable and efficient message transmission Feb 19, 2024 pm 10:12 PM

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

See all articles