Akka.net持久性演员没有从Fallback Config获得连接字符串?

时间:2017-03-22 07:19:40

标签: akka akka.net akka-cluster akka-persistence akka-persistent-fsm

我在app.config文件中有我的主hocon配置,并尝试使用fallback config从代码后面设置连接字符串。但是当演员系统开始时它并没有起作用。这是我的hocon配置和C#代码如下。有人能帮帮我吗?

Hocon配置我已经注释掉connnection-string以从fallback配置中获取它         akka.persistence {

      journal {
        plugin = "akka.persistence.journal.sql-server"                
        sql-server {
              class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"
              plugin-dispatcher = "akka.actor.default-dispatcher"

              # connection string used for database access
              # connection-string = "Data Source=ES-NB-046\\MSSQLSERVER_2014;Initial Catalog=PSAkka;User ID=sa;Password=1qaz2wsx@;"
              # can alternativly specify: connection-string-name

              # default SQL timeout
              connection-timeout = 30s

              # SQL server schema name
              schema-name = dbo

              # persistent journal table name
              table-name = EventJournal

              # initialize journal table automatically
              auto-initialize = on

              timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"
              metadata-table-name = Metadata
        }
      }

文件背后的C#代码

 static void Main(string[] args)
 {

    var mainConfig = ConfigurationFactory.Load();

    string connectionString = @"akka.persistence.journal.sql-server.connection-string = ""Data Source=Data Source=ES-NB-046\\MSSQLSERVER_2014;Initial Catalog=PSAkka;User ID=sa;Password=1qaz2wsx@;""";
    //string text1 = @"akka.persistence.journal.sql-server.abc = ""Data Source=Data Source=ES-NB-046\\MSSQLSERVER_2014;Initial Catalog=PSAkka;User ID=sa;Password=1qaz2wsx@;""";

    var conStringConfig = ConfigurationFactory.ParseString(connectionString);

    mainConfig = mainConfig.WithFallback(conStringConfig);

    System = ActorSystem.Create("Game", mainConfig);

    PlayerCoordinator = System.ActorOf<PlayerCoordinatorActor>("PlayerCoordinator");

1 个答案:

答案 0 :(得分:0)

代码后面的连接字符串有两次有数据源的错误

string connectionString = @“akka.persistence.journal.sql-server.connection-string =”“数据源=数据源= ES-NB-046 \ MSSQLSERVER_2014;初始目录= PSAkka;用户ID = sa;密码= 1qaz2wsx @ “;”“;

之后它起作用是我的错误

查看主题https://github.com/akkadotnet/akka.net/issues/2565