0

当我尝试使用 SQL Server 持久性创建持久性 Actor 时,出现上述错误。

编辑:当我克隆存储库 akka 和 akka 持久性 sql 服务器并附加然后使用 nuget 包按预期工作时,这很奇怪。我正在使用以下版本: "Akka" Version="1.4.11" "Akka.Persistence.SqlServer" Version="1.4.10"

 akka {
  persistence{
    journal {
            plugin = "akka.persistence.journal.sql-server"
        sql-server {
            # qualified type name of the SQL Server persistence journal actor
            class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"

            # dispatcher used to drive journal actor
            plugin-dispatcher = "akka.actor.default-dispatcher"

            # connection string used for database access
            connection-string = "my con string"

            # default SQL commands timeout
            connection-timeout = 30s

            # SQL server schema name to table corresponding with persistent journal
            schema-name = dbo

            # SQL server table corresponding with persistent journal
            table-name = EventJournal

            # should corresponding journal table be initialized automatically
            auto-initialize = on

            # timestamp provider used for generation of journal entries timestamps
            timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"

            # metadata table
            metadata-table-name = Metadata
            
            # Recommended: change default circuit breaker settings
            # By uncommenting below and using Connection Timeout + Command Timeout
            # circuit-breaker.call-timeout=30s
        }
    }

    snapshot-store {
            plugin = "akka.persistence.snapshot-store.sql-server"
        sql-server {

            # qualified type name of the SQL Server persistence journal actor
            class = "my con string"

            # dispatcher used to drive journal actor
            plugin-dispatcher = "akka.actor.default-dispatcher"

            # connection string used for database access
            connection-string = "xyz"

            # default SQL commands timeout
            connection-timeout = 30s

            # SQL server schema name to table corresponding with persistent journal
            schema-name = dbo

            # SQL server table corresponding with persistent journal
            table-name = SnapshotStore

            # should corresponding journal table be initialized automatically
            auto-initialize = on
            
            # Recommended: change default circuit breaker settings
            # By uncommenting below and using Connection Timeout + Command Timeout
            # circuit-breaker.call-timeout=30s
        }
    }
}         

}

我的协调员正在尝试为每个消息 ID 创建演员,但失败并出现错误:

创建具有 1 个参数的 Akka.Persistence.SqlServer.Journal.SqlServerJournal 类型的参与者实例时出错:(类:“Akka.Persistence.SqlServer.Journal.SqlServerJournal,Akka.Persistence.SqlServer”插件调度程序:akka.actor.default-调度程序连接字符串:“xyz”连接超时:30s 模式名称:dbo 表名称:EventJournal 自动初始化:时间戳提供者:“Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql .Common" 元数据表名:元数据顺序访问:on ) 原因:: Akka.Actor.ActorInitializationException: 创建期间出现异常 ---> System.TypeLoadException: 创建 Akka.Persistence.SqlServer.Journal 类型的 Actor 实例时出错.SqlServerJournal 带 1 个参数:(类:“Akka.Persistence.SqlServer.Journal.SqlServerJournal,Akka。Persistence.SqlServer”插件调度程序:akka.actor.default-dispatcher 连接字符串:“xyz”连接超时:30 秒模式名称:dbo 表名称:EventJournal 自动初始化:时间戳提供程序:“Akka.Persistence .Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common" 元数据表名:元数据顺序访问:on ) ---> System.Reflection.TargetInvocationException:调用目标已抛出异常---> System.MissingMethodException: Method not found: 'Void Akka.Pattern.CircuitBreaker..ctor(Int32, System.TimeSpan, System.TimeSpan)'. at Akka.Persistence.Journal.AsyncWriteJournal..ctor() at Akka.Persistence.Sql.Common.Journal.SqlJournal..ctor(Config journalConfig) 在 Akka.Persistence.SqlServer.Journal.SqlServerJournal..ctor(Config journalConfig)ctor(配置日志配置)

public class MyCoordinatorActor : ReceiveActor
    {
        public MyCoordinatorActor ()
        {
            Receive<MyMessage>(message =>
            {
                var childName = message.Id.ToString();

                var child = Context.Child(childName);
                if (child.IsNobody())
                {
                    var props = Props.Create(() => new AuctionActor(childName));
                    child = Context.ActorOf(props, childName);
                }
                child.Tell(message);
            });
        }
    }

  

public class MyActor : ReceivePersistentActor
{
        private decimal _currentValue;
        public override string PersistenceId { get; }

        public AuctionActor(string Id)
        {
            PersistenceId = Id;
            Command<BidMessage>(message =>
            {
                if (message.Value > _currentValue)
                {

                    Persist(message, mssage =>
                    {
                        _currentValue = mssage.Value;
                       
                    });
     
                }
                else
                {
              
                }

            });
           
        }


    }
4

1 回答 1

1

您遇到了这个问题,这是我们在CircuitBreakerAkka.NET v1.4.11 中更改了一些 API 的结果:https ://github.com/akkadotnet/Akka.Persistence.SqlServer/issues/177

几分钟前,我们刚刚推送了 Akka.Persistence.SqlServer 1.4.11:https ://github.com/akkadotnet/Akka.Persistence.SqlServer/releases/tag/1.4.11 - 升级到这个版本应该可以解决您的问题。

于 2020-11-11T23:49:32.467 回答