-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Sent async message in the loop causes an exception #62
Comments
Thanks, Does it mean had fixed this bug at the latest nuget package version:2.1.1-preview-28414190 ? |
@ajdwfnhaps Yes, you can do a test ! |
Version 2.1.1 has been released and fixed this bug. |
Got it. Great |
使用v2.1.1,现在没有在循环里,但异步发送MQ消息,偶尔还会报错
[2017-11-30 10:50:00.7802] [] [WARN ] [DotNetCore.CAP.SubscribeQueueExecutor]: |
@ajdwfnhaps 你这个可能是由于DI生命周期的问题,改成这样试一下 public class AccountPeriodJob : JobBase
{
private readonly ILogger _logger;
private readonly IServiceProvider _serviceProvider;
public AccountPeriodJob(ILogger<AccountPeriodJob> logger, IServiceProvider serviceProvider)
{
_logger = logger;
_serviceProvider = serviceProvider;
}
protected override async Task Invoke(IJobExecutionContext context)
{
using (var scope = _serviceProvider.CreateScope())
{
var provider = scope.ServiceProvider;
var accountPeriodService = provider.GetRequiredService<IAccountPeriodService>();
await accountPeriodService.SendAccountPeriodMQMessageAsync();
}
_logger.LogInformation("AccountPeriodJob Runing...");
}
} |
谢谢你的建议,我按照你提供的方法试了一下,问题仍然存在,但如果我换成同步发送(_capBus.Publish),就不会出现这个问题 |
Async publish message in controller or services with the loop :
This type of sent can lead to an exception !
The text was updated successfully, but these errors were encountered: