Comments (15)
把你项目上传到github我看一下配置和结构
from cap.
from cap.
PS: 同时启动了这两个项目
"MultiProjectConfigurations": {
"Quartz + CAP": {
"Projects": {
"AAM.Quartz.Web": {},
"AAM.Finance.CAP": {}
}
}
}
from cap.
无用代码太多了,你可以把没用代码都删除掉,而且我没有数据库也运行不起来,建议能够使用最简单的代码能够把你的问题复现出来。
这个地方是一个长的调用链吗? 是消费了之后又要发送到其他消息进行消费? 为什么你的publlish方法没有在事务里面呢?
from cap.
好的,我删除了一些没用的代码,去掉了数据库,除了两个cap1 cap2的库,
现在换了cap的两个库的连接串和MQ的配置就可以跑起来的了。
您截图的地方,是长的调用链来的,一批MQ消息消费完后,跟着一个eof结束的标识消息,然后触发下一步汇总的处理,我eof的publish没有包在事务里,因为它是消费结束的标识,没有其它数据库操作事务。
我调整完这些代码后,还使用了Mysql 5.5.44-0ubuntu0.12.04.1测试了一下,问题仍旧,希望能够找到原因,使CAP能更完善,非常感谢
from cap.
from cap.
Hi @ajdwfnhaps ~
我已经在 2.1.2-preview-28879945
版本修复了这个bug,谢谢你的反馈。
如果还有其他问题,可以 reopen 此 issue。
from cap.
太好了,非常感谢,我这边已更新测试过了,现在没问题了
from cap.
BTW,能否用我这个示例项目修改为异步发送MQ消息测试一下(PublishAsync),我这边测试异步发送就有可能报以下这个错误:
[2017-12-01 15:39:12.3830] [] [ERROR] [AAM.Quartz.Tasks.Finance.AccountPeriodJob]: Job执行中发生错误,ErrMsg:There is already an open DataReader associated with this Connection which must be closed first. System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first. at MySqlConnector.Core.ServerSession.StartQuerying(MySqlCommand command) in C:\projects\mysqlconnector\src\MySqlConnector\Core\ServerSession.cs:line 115 at MySqlConnector.Core.TextCommandExecutor.<ExecuteReaderAsync>d__3.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\Core\TextCommandExecutor.cs:line 66 --- 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 MySqlConnector.Core.TextCommandExecutor.<ExecuteNonQueryAsync>d__1.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\Core\TextCommandExecutor.cs:line 25 --- 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 MySql.Data.MySqlClient.MySqlTransaction.<CommitAsync>d__2.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlTransaction.cs:line 27 --- 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 MySql.Data.MySqlClient.MySqlTransaction.Commit() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlTransaction.cs:line 13 at DotNetCore.CAP.Abstractions.CapPublisherBase.ClosedCap() in D:\Work\aimei_finance\trunk\code\aimei_finance\CAP\DotNetCore.CAP\Abstractions\CapPublisherBase.cs:line 162 at DotNetCore.CAP.Abstractions.CapPublisherBase.<PublishWithTransAsync>d__35.MoveNext() in D:\Work\aimei_finance\trunk\code\aimei_finance\CAP\DotNetCore.CAP\Abstractions\CapPublisherBase.cs:line 137 --- 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 AAM.Quartz.Domain.Service.Finance.AccountPeriodService.<Execute>d__7.MoveNext() in D:\Work\aimei_finance\trunk\code\aimei_finance\Quartz\AAM.Quartz.Domain.Service\Finance\Implementation\AccountPeriodService.cs:line 70 --- 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 AAM.Quartz.Tasks.Finance.AccountPeriodJob.<Invoke>d__3.MoveNext() in D:\Work\aimei_finance\trunk\code\aimei_finance\Quartz\AAM.Quartz.Task\Finance\AccountPeriodJob.cs:line 32 --- 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 AAM.Quartz.Tasks.JobBase.<Execute>d__3.MoveNext() in D:\Work\aimei_finance\trunk\code\aimei_finance\Quartz\AAM.Quartz.Task\JobBase.cs:line 40
from cap.
你的项目我已经运行起来了,怎么样发消息呢? @ajdwfnhaps
我需要运行 tables_mysql_innodb.sql 生成表吗?
你还需要补充说明一下你这个项目的运行原理
from cap.
@yuleyule66 不需要运行sql的,您跑起来后有这个Job吗,有就手动执行一下就可以发消息的了
如果没有这个Job,需要替换一下quartz.db这个Sqlite数据库,位置在项目AAM.Quartz.Web\Persistence\SQLite
from cap.
启动 AAM.Quartz.Web
访问 :http://localhost:10931/
出现下面这个错误:
{"Success":-1,"Title":"全局异常处理中间件返回信息","Msg":"错误代码:200,提示信息:Failed to obtain DB connection from data source 'default': Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 14: 'unable to open database file'.\r\n at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)\r\n at Microsoft.Data.Sqlite.SqliteConnection.Open()\r\n at Quartz.Impl.AdoJobStore.JobStoreSupport.GetConnection()"}
from cap.
不好意思,还有一步,AAM.Quartz.Web 的appsetting.json 要配置一下quartz.db的连接串信息:
from cap.
这个问题是由于并发冲突导致。
因为连接池的问题,不同线程获取到了相同的连接,mysql不支持同一个连接一边DataReader读,一边进行Execute。
默认情况下,在PublishAsync内部会开启事务,当CAP检测的外围事务时,会使用外围事务。
手动开启事务,会大大降低这种概率发生的可能性。
using (var trans = await _dbContext.Database.BeginTransactionAsync())
{
for (int i = 0; i < 1000; i++)
{
await _capBus.PublishAsync("sample.test.testsend", DateTime.Now);
}
trans.Commit();
}
from cap.
好的,谢谢,我稍后就试吓
from cap.
Related Issues (20)
- Use SqlLite ,how to use subscribe groupname,groupname dynamic generate. HOT 1
- 集群部署时需要多个实例都接受消息如何处理 HOT 1
- How to implement transaction Pub/Sub using CAP & FreeSql using demo? HOT 2
- CAP has not been started! HOT 4
- Question about parallel execution HOT 6
- Error in Nats transport HOT 4
- 能不能加个配置,可以单独启用消费功能或发送功能 ? HOT 2
- How to Introduce Multiple Database Providers? HOT 1
- .NET Core 8 使用RabbitMQ 报No ip address could be resolved for【hostName】的问题 HOT 1
- Optimizing RabbitMQ Performance and Managing Multiple Instances in CAP HOT 2
- Feature Request: Per-Queue Configuration for BasicQos and ConsumerThreadCount HOT 3
- 消息持久化支持达梦数据库吗 HOT 1
- Is the message data structure compatible with older versions of 3.0? HOT 1
- Add new option for parallel publish send. HOT 2
- Add option for controlling reponse headers from OnSubscribeExecuted HOT 2
- NATS Connection Error after Restarting nats-server: Unable to Publish Messages HOT 5
- SQL Server replication readpast error! "You can only specify the READPAST lock in the READ COMMITTED or REPEATABLE READ isolation levels" HOT 3
- 一个进程内可以创建多个CAP吗? HOT 1
- NATS feature: add the possibility to disable dynamic consumer subject/topic creation through NatsCapOtpions HOT 2
- 一个程序进程会操作多个不同的业务数据库,参考#998创建多个发布者进行对应处理,消费者应该如何处理消息? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cap.