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

IConsumerInvokerFactory lifetime cause unexpected subscription callback function exceptions #34

Closed
standardcore opened this issue Aug 17, 2017 · 2 comments

Comments

@standardcore
Copy link

commented Aug 17, 2017

IConsumerInvokerFactory的生命周期为单例,导致消费者回调函数中注入的依赖对象全部都是单例,一旦销毁某个对象,将导致后续所有回调全部失败。

Sample:

public async Task<bool> SampleCallback()

{
    using(var connection = _dbContext.Database.GetDbConnection())
    {
        await connection.OpenAsync();
    }
    return true;
}

以上代码中,_dbContext 通过构造函数注入进来,并在函数执行离开using域时销毁数据库连接,导致第二次进入此函数时抛出异常。

@standardcore standardcore changed the title IConsumerInvokerFactory生命周期问题 IConsumerInvokerFactory lifetime cause unexpected callback result Aug 17, 2017

@standardcore standardcore changed the title IConsumerInvokerFactory lifetime cause unexpected callback result IConsumerInvokerFactory lifetime cause unexpected subscription callback function exceptions Aug 17, 2017

@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Aug 17, 2017

"消费者回调函数" 指的是什么?


I got it, this is a bug, thanks for your feedback.

@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Aug 18, 2017

version 2.0 preview published, the problem has now been solved.

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