当前位置:网站首页>The receiver sets the concurrency and current limit
The receiver sets the concurrency and current limit
2022-07-27 05:22:00 【A dream without trace BZY】
1、 Receiver code
package com.example.demo.mq;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
@Component
public class Test1QueueReceiver {
//concurrency = "2-5" Indicates that this queue is the smallest 2 individual , Maximum 5 Consumers
//mqlistenerContainer Need to be in config Middle configuration
@RabbitListener(queues = "test1_Queue",concurrency = "2-5",containerFactory = "mqlistenerContainer")
public void process(String mes, Channel channel, Message message) {
System.err.println(mes);
// All relevant information of the message can be found in message Find
System.err.println(message.toString());
}
}
2、 stay RabbitmqConfig Middle configuration mqlistenerContainer
@Autowired
private CachingConnectionFactory connectionFactory;
/** * Current limiting * @return */
@Bean(name = "mqlistenerContainer")
public SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory(){
SimpleRabbitListenerContainerFactory factory=new SimpleRabbitListenerContainerFactory();
factory.setConnectionFactory(connectionFactory);
factory.setPrefetchCount(75);
return factory;
}
Complete the above , View queue information on the console 
At this time, there are two consumers , When there are too many messages in the queue, it will become 5 Consumers . The upper limit of messages received per consumer per unit time is 75 strip
边栏推荐
- Typescript details
- 一、MySQL基础
- Gradio quickly builds ml/dl Web Services
- 整合SSM
- 2021 OWASP top 5: security configuration error
- 1、 MySQL Foundation
- How to sinicize the JMeter interface?
- The interface can automatically generate E and other asynchronous access or restart,
- mq常见问题
- JVM上篇:内存与垃圾回收篇九--运行时数据区-对象的实例化,内存布局与访问定位
猜你喜欢

JVM Part 1: memory and garbage collection -- runtime data area 4 - program counter

Gradio quickly builds ml/dl Web Services

Database design - relational data theory (ultra detailed)

JVM上篇:内存与垃圾回收篇二--类加载子系统

35. Scroll

BIO、NIO、AIO区别

B1021 single digit statistics

JVM上篇:内存与垃圾回收篇十--运行时数据区-直接内存

Inspiration from "flying man" Jordan! Another "arena" opened by O'Neill

JVM Part 1: memory and garbage collection part 8 - runtime data area - Method area
随机推荐
SSM framework integration
Use ngrok for intranet penetration
DBUtils
Use of collection framework
How to test the payment process?
Acticiti中startProcessInstanceByKey方法在variable表中的如何存储
LeetCode刷题之322 Coin Change
弹球小游戏
B1028 census
知识点总结(一)
B1025 反转链表*******
Inspiration from "flying man" Jordan! Another "arena" opened by O'Neill
34. Analyze flexible.js
B1022 a+b in d-ary
Find the number of combinations (the strongest optimization)
B1021 single digit statistics
[acwing] solution to the 61st weekly match
idea远程调试debug
Prime number screening (Ehrlich sieve method, interval sieve method, Euler sieve method)
Interface and abstract class / method learning demo