Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When RabbitMQ is reconnected due to network reasons, the reconnection log is occasionally triggered to continuously output #1140

Closed
hanlinking opened this issue May 23, 2022 · 7 comments

Comments

@hanlinking
Copy link

hanlinking commented May 23, 2022

我们在使用过程出现了一个问题,就是当我们使用rabbitmq作为队列,并且在使用过程中中断队列,然后重新启动,有一定的概率导致无限的重连。
image
测试上是部署k8s环境,有两个pod,rabbitmq掉线重连后,其中一个pod正常了,但是另外一个pod一直都在尝试重连
使用代码也比较简单

services.AddCap(option =>
        {
            // 消息存储
            option.UseEntityFramework<FrontDbContext>(o => o.Schema = "FRONT");
            // option.RegisterExtension(new CustomCapOptionExtension());
            // 消息队列
            option.UseRabbitMQ(cfg =>
            {
                cfg.HostName = configuration["Cap:RabbitMQ:HostName"];
                cfg.UserName = configuration["Cap:RabbitMQ:UserName"];
                cfg.Password = configuration["Cap:RabbitMQ:Password"];
                cfg.Port = configuration.GetValue("Cap:RabbitMQ:Port", 5672);
            });
            option.DefaultGroupName = configuration.GetValue<string>("Cap:DefaultGroupName", "cap.queue.hr.sbcc.esop.front");
            option.FailedRetryCount = configuration.GetValue("Cap:FailedRetryCount", 10);
            option.FailedRetryInterval = configuration.GetValue("Cap:FailedRetryInterval", 30);
            option.SucceedMessageExpiredAfter = configuration.GetValue("Cap:SucceedMessageExpiredAfter", 86400);
            option.ConsumerThreadCount = configuration.GetValue("Cap:ConsumerThreadCount", 1);
        });

CAP 版本:6.0.1
image

@yang-xiaodong
Copy link
Member

Please report the version and the cap logs

@hanlinking
Copy link
Author

Please report the version and the cap logs

代码版本是:6.0.1 拷贝了ConsumerRegister 加了点日志,目前我调试下来,是由于rabbitmq网络抖动,出现短暂的掉线,就会触发这个bug
image

@yang-xiaodong
Copy link
Member

执行取消操作是什么意思?消费者抛出取消异常?

@hanlinking
Copy link
Author

image

@yang-xiaodong yang-xiaodong changed the title 关于使用rabbitmq作为队列,断线重连后有概率导致触发无限重连日志 When RabbitMQ is reconnected due to network reasons, the reconnection log is occasionally triggered to continuously output Jun 1, 2022
@yang-xiaodong
Copy link
Member

你好,这个问题我这边无法重现。按照你的说明,短暂掉线也无法重现,请提供一下重现步骤。

如果你可以重现,请测试下取消后等待2秒是否可以解决?

public void Pulse()
{
    _cts.Cancel();
    _cts.Dispose();
    _compositeTask?.Wait(TimeSpan.FromSeconds(2));   //添加此行
}

@hanlinking
Copy link
Author

你好,这个问题我这边无法重现。按照你的说明,短暂掉线也无法重现,请提供一下重现步骤。

如果你可以重现,请测试下取消后等待2秒是否可以解决?

public void Pulse()
{
    _cts.Cancel();
    _cts.Dispose();
    _compositeTask?.Wait(TimeSpan.FromSeconds(2));   //添加此行
}

目前我通过修改下图做法解决
image

yang-xiaodong added a commit that referenced this issue Jun 8, 2022
@yang-xiaodong
Copy link
Member

Fixed in v6.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants