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

Sending multiple messages within a request will cause an exception #25

Closed
kulend opened this issue Aug 11, 2017 · 5 comments

Comments

@kulend
Copy link

commented Aug 11, 2017

RabbitMQ,MySql环境
在同一个请求内两次Publish消息,第二次发送错误。
是bug还是我写的有问题?

`
//发送消息

        await _eventPublisher.PublishAsync("msg1", new UserLoginEvent {UserId = entity.Id});
        try
        {
            await _eventPublisher.PublishAsync("backend_user_action_log", log);
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            throw;
        }

`

Exception

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'MySqlConnection'. at MySql.Data.MySqlClient.MySqlConnection.VerifyNotDisposed() at MySql.Data.MySqlClient.MySqlConnection.<OpenAsync>d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Dapper.SqlMapper.<ExecuteImplAsync>d__29.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at DotNetCore.CAP.MySql.CapPublisher.<PublishWithTransAsync>d__24.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at DotNetCore.CAP.MySql.CapPublisher.<PublishCoreAsync>d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Aug 11, 2017

Thanks for your feedback. I will check it later.

@yang-xiaodong yang-xiaodong added the bug label Aug 11, 2017

@ghost

This comment has been minimized.

Copy link

commented Aug 11, 2017

It related to inner db connection management strategy was not ready. Suppose injected the publisher using "AddTransient" in aspnetcore, then connection should be released in dispose part. The only problem is there is too many db connection instance, manage them safely is not easy.

@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Aug 11, 2017

This occurs because the incorrect dispose of EF connection. I have fixed this bug and I will release a new preview version later.

@yang-xiaodong yang-xiaodong added the fixed label Aug 11, 2017

yang-xiaodong added a commit that referenced this issue Aug 14, 2017
yang-xiaodong added a commit that referenced this issue Aug 15, 2017
@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Aug 18, 2017

2.0 preview published, the problem has now been solved.

@ajdwfnhaps

This comment has been minimized.

Copy link

commented Nov 23, 2017

我今天使用v2.1.0 遇到同样的问题 我明天把异常信息发布上来 提个issue
aspnetcore2.0
ef core2.0
quazt.net
autofac

@yang-xiaodong yang-xiaodong changed the title 同一个请求内多次发布消息出错,提示MySqlConnection已disposed掉 Sending multiple messages within a request can cause an exception Nov 25, 2017

@yang-xiaodong yang-xiaodong changed the title Sending multiple messages within a request can cause an exception Sending multiple messages within a request will cause an exception Nov 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.