Comments (10)
consumer孤零零的,过一会gc就该来收割它啦。
可以搞一个数组,把这些消费者对象管理起来
from newlife.rocketmq.
创建消费者的时候,没有必要异步,直接for循环好了,因为Start只是启动内部线程,并不阻塞
from newlife.rocketmq.
consumer孤零零的,过一会gc就该来收割它啦。 可以搞一个数组,把这些消费者对象管理起来
怎么管理呢?定时判断消费者是否存在吗?不存在了就重新创建一个新的?
from newlife.rocketmq.
弄一个全局变量,或者静态变量都行,只要有引用,GC就不会销毁它
from newlife.rocketmq.
弄一个全局变量,或者静态变量都行,只要有引用,GC就不会销毁它
好的,谢谢,另外一个问题,请有可以获取topic下queueid的方法吗?尝试用Queues,好像不行
from newlife.rocketmq.
弄一个全局变量,或者静态变量都行,只要有引用,GC就不会销毁它
public static List listConsumer = new List();
public void Start()
{
for (int i = 0; i < 3; i++)
{
var consumer = new Consumer
{
Topic = "bb",
NameServerAddress = "xx",
BatchSize = 3,
Group = "bbgroup"
};
consumer.OnConsume = (q, ms) =>
{
string mInfo = $"datetime={DateTime.Now},BrokerName={q.BrokerName},QueueId={q.QueueId},Length={ms.Length}";
Console.WriteLine(mInfo);
foreach (var item in ms.ToList())
{
string msg = $"消息:msgId={item.MsgId},key={item.Keys},产生时间【{item.BornTimestamp.ToDateTime()}】,内容>{item.BodyString}";
LogHelper.Information("RocketMQConsumer", msg);
}
// return false;//通知消息队:不消费消息
return true; //通知消息队:消费了消息
};
consumer.Start();
listConsumer.Add(consumer);
}
}
这样用listConsumer来管理,还是只会执行一次,麻烦帮看下,谢谢
from newlife.rocketmq.
嗯,是这样,代码没有错。
可以看看日志。
from newlife.rocketmq.
感谢团队大佬贡献
from newlife.rocketmq.
问题解决了吗?
from newlife.rocketmq.
问题解决了吗?
解决了自动回收的问题,但是现在吃内存和CPU很历害,跑一会儿就占内存几G了。
from newlife.rocketmq.
Related Issues (20)
- consumer.Start();出现问题 HOT 6
- .NET5 Could not load file or assembly 'NewLife.Core, Version=9.0.8098.19786 HOT 1
- 消费者 consume 支持异步 HOT 2
- 支持指定消费模式吗? 就是指定集群还是广播模式 HOT 4
- 双主集群 HOT 7
- 消费者始终不触发OnConsume回调,不知道原因 HOT 3
- 消费者的消费问题 HOT 6
- 请问消费者支持push模式吗 HOT 3
- 不支持RocketMQ4.6.0版本中增加的request-reply新特性 HOT 2
- rmq版本4.7.1,运行一段时间后会提示: FATAL | The service threw an unhandled exceptio HOT 6
- 请问下 Header 里面为啥要截断异常信息,这样设计的目的是啥哦? HOT 1
- 新增一个Redis交换机项目,能够把消息队列消费到的数据发送给webapi接口,同时提供webapi接口供使用方发布消息
- 有辦法支援 Broadcast 嗎 HOT 3
- 支持 RocketMQ 5.0 POP 消费模式
- 是否支持集群消费 HOT 9
- rocketmq origin msgid is diffent with sdk parse HOT 3
- 消息消费不掉问题 HOT 2
- 消费端发布到服务器上报错 HOT 4
- 消费者会时不时的位移消费位置 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from newlife.rocketmq.