请教 Quartz 多个 Job 同时执行 事务如何使用 #870
wangchaoit
started this conversation in
Show and tell
Replies: 2 comments 2 replies
-
Quartz 有每次 job 执行可能不是 Scoped 生命周期。 用相同在代码在 webapi controller 测试一下。 |
Beta Was this translation helpful? Give feedback.
1 reply
-
Quartz 的Job执行代码内如果使用依赖注入获取服务,应该使用独立的Scope对象,自己控制释放或使用单例,而不应该依赖首次触发服务启动的Scope,比如HttpContext |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
请问各位大佬,我有一个项目使用Quartz做调度,使用了Freesql。
现在实现的方式分以下几步:
1、 在 IOC 中注入 UnitOfWorkManager 。 如: services.AddScoped();
2、在每一个Job的构造函数中获取 UnitOfWorkManager 和 IBaseRepository《users》 users
3、在任务执行中使用 users.InsertAsync update 等操作
现在遇到的问题:
1、经常报错:
There is already an open DataReader associated with this Connection which must be closed first.
2、表死锁
3、报错:
【主库】状态不可用,等待后台检查程序恢复方可使用
我感觉是我使用的方法有问题,但是由于能力有限无法解决,特来求教,希望知道的大佬帮帮我,先谢了!
Beta Was this translation helpful? Give feedback.
All reactions