Giter VIP home page Giter VIP logo

Comments (15)

yang-xiaodong avatar yang-xiaodong commented on July 21, 2024

把你项目上传到github我看一下配置和结构

from cap.

ajdwfnhaps avatar ajdwfnhaps commented on July 21, 2024

@yuleyule66 请查看

from cap.

ajdwfnhaps avatar ajdwfnhaps commented on July 21, 2024

PS: 同时启动了这两个项目

 "MultiProjectConfigurations": {
    "Quartz + CAP": {
      "Projects": {
        "AAM.Quartz.Web": {},
        "AAM.Finance.CAP": {}
      }
    }

  }

from cap.

yang-xiaodong avatar yang-xiaodong commented on July 21, 2024

无用代码太多了,你可以把没用代码都删除掉,而且我没有数据库也运行不起来,建议能够使用最简单的代码能够把你的问题复现出来。

image

这个地方是一个长的调用链吗? 是消费了之后又要发送到其他消息进行消费? 为什么你的publlish方法没有在事务里面呢?

from cap.

ajdwfnhaps avatar ajdwfnhaps commented on July 21, 2024

好的,我删除了一些没用的代码,去掉了数据库,除了两个cap1 cap2的库,
现在换了cap的两个库的连接串和MQ的配置就可以跑起来的了。

您截图的地方,是长的调用链来的,一批MQ消息消费完后,跟着一个eof结束的标识消息,然后触发下一步汇总的处理,我eof的publish没有包在事务里,因为它是消费结束的标识,没有其它数据库操作事务。

我调整完这些代码后,还使用了Mysql 5.5.44-0ubuntu0.12.04.1测试了一下,问题仍旧,希望能够找到原因,使CAP能更完善,非常感谢

from cap.

ajdwfnhaps avatar ajdwfnhaps commented on July 21, 2024

最新的已提交到主分支里

from cap.

yang-xiaodong avatar yang-xiaodong commented on July 21, 2024

Hi @ajdwfnhaps ~
我已经在 2.1.2-preview-28879945 版本修复了这个bug,谢谢你的反馈。

如果还有其他问题,可以 reopen 此 issue。

from cap.

ajdwfnhaps avatar ajdwfnhaps commented on July 21, 2024

太好了,非常感谢,我这边已更新测试过了,现在没问题了

from cap.

ajdwfnhaps avatar ajdwfnhaps commented on July 21, 2024

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.

yang-xiaodong avatar yang-xiaodong commented on July 21, 2024

你的项目我已经运行起来了,怎么样发消息呢? @ajdwfnhaps

我需要运行 tables_mysql_innodb.sql 生成表吗?

你还需要补充说明一下你这个项目的运行原理

from cap.

ajdwfnhaps avatar ajdwfnhaps commented on July 21, 2024

@yuleyule66 不需要运行sql的,您跑起来后有这个Job吗,有就手动执行一下就可以发消息的了

image

如果没有这个Job,需要替换一下quartz.db这个Sqlite数据库,位置在项目AAM.Quartz.Web\Persistence\SQLite

quartz.zip

from cap.

yang-xiaodong avatar yang-xiaodong commented on July 21, 2024

启动 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.

ajdwfnhaps avatar ajdwfnhaps commented on July 21, 2024

不好意思,还有一步,AAM.Quartz.Web 的appsetting.json 要配置一下quartz.db的连接串信息:

image

from cap.

yang-xiaodong avatar yang-xiaodong commented on July 21, 2024

这个问题是由于并发冲突导致。

因为连接池的问题,不同线程获取到了相同的连接,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.

ajdwfnhaps avatar ajdwfnhaps commented on July 21, 2024

好的,谢谢,我稍后就试吓

from cap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.