Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Akka.net persistence actor doesn't get connection string from Fallback Config? #2565

Closed
amalshalika opened this issue Mar 22, 2017 · 5 comments

Comments

@amalshalika
Copy link

I have my main hocon config in app.config file and try to set connection string from code behind using fallback config. but when actor system start it doesn't working. here is my hocon config and C# code as below.

Hocon config i have comment out connnection-string to take it from fallback config
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# code behind file

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");
@Horusiath
Copy link
Contributor

Have you tried to reverse mainConfig.WithFallback(conStringConfig) to conStringConfig.WithFallback(mainConfig)?

@amalshalika
Copy link
Author

Yes i did it also but not work

@Horusiath
Copy link
Contributor

What error did you get exactly? May it be malformed connection string? (the one you've shown in your snipped probably is)

Optionally if you want to load connection string from *.config section you may use connection-string-name.

@amalshalika
Copy link
Author

Actually error i am getting is

[ERROR][3/22/2017 8:29:43 AM][Thread 0006][[akka://Game/user/PlayerCoordinator#1256963396]] Persistence failure when replaying events for persistenceId [player-coordinator]. Last known sequence number [0] Cause: Akka.Persistence.RecoveryTimedOutException: Recovery timed out, didn't get event within 30s, highest sequence number seen 0.

connection string load from config file is working fine. as you can see I was comment out that one because i have a requirement of setting it from C# code behind just before actor system initialize. I just comment connection-string key from config file and instead used fallback config with same key and same connection string values. but it doesn't load and unable to replay message and deliver

@amalshalika
Copy link
Author

Yes connection is malformed. it is my fault once it corrected work fine thanks for help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants