Mark Ewer
Mark Ewer

Reputation: 1835

Is there a working example of Akka.net Persistence with MongoDb out there anywhere?

I am attempting to configure Akka.Net with journal persistence to MongoDb but it is throwing an exception that I can't quite figure out. Is there a reference example out there anywhere I can look at to see how this is supposed to work? I would have expected the examples in the unit tests to fill this need for me but the tests are missing for the MongoDb implementation of persistence. :(

Here's the error I am getting:

Akka.Actor.ActorInitializationException : Exception during creation ---> 
System.TypeLoadException : Method 'ReplayMessagesAsync' in type 
'Akka.Persistence.MongoDb.Journal.MongoDbJournal' from assembly 
'Akka.Persistence.MongoDb, Version=1.0.5.2, Culture=neutral, PublicKeyToken=null' 
does not have an implementation.

and here is my HOCON for this app: ---Edit - Thanks for the tip Horusiath; based on that I updated to this HOCON and the Sqlite provider works but the MongoDb one is still giving an error.

  <![CDATA[
    akka {  
        actor {
            provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
        }
        remote {
            helios.tcp {
                port = 9870 #bound to a specific port
                hostname = localhost
            }
        }
        persistence {
            publish-plugin-commands = on
            journal {
                #plugin = "akka.persistence.journal.sqlite"
                plugin = "akka.persistence.journal.mongodb"
                mongodb {
                    class = "Akka.Persistence.MongoDb.Journal.MongoDbJournal, Akka.Persistence.MongoDb"
                    connection-string = "mongodb://localhost/Akka"
                    collection = "EventJournal"
                }
                sqlite {
                    class = "Akka.Persistence.Sqlite.Journal.SqliteJournal, Akka.Persistence.Sqlite"
                    plugin-dispatcher = "akka.actor.default-dispatcher"
                    connection-string = "FullUri=file:Sqlite-journal.db?cache=shared;"
                    connection-timeout = 30s
                    schema-name = dbo
                    table-name = event_journal
                    auto-initialize = on
                    timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"
                }
            }
            snapshot-store {
                #plugin = "akka.persistence.snapshot-store.sqlite"
                plugin = "akka.persistence.snapshot-store.mongodb"
                mongodb {
                    class = "Akka.Persistence.MongoDb.Snapshot.MongoDbSnapshotStore, Akka.Persistence.MongoDb"
                    connection-string = "mongodb://localhost/Akka"
                    collection = "SnapshotStore"
                }
                sqlite {
                          class = "Akka.Persistence.Sqlite.Snapshot.SqliteSnapshotStore, Akka.Persistence.Sqlite"
                          plugin-dispatcher = "akka.actor.default-dispatcher"
                          connection-string = "FullUri=file:Sqlite-journal.db?cache=shared;"
                          connection-timeout = 30s
                          schema-name = dbo
                          table-name = snapshot_store
                          auto-initialize = on
                      }
              }
          }
      }
  ]]>
</hocon>

So, back to my original question: Is there are working MongoDb sample that I can examine to learn how this is intended to work?

Upvotes: 0

Views: 1058

Answers (2)

Aaronontheweb
Aaronontheweb

Reputation: 8404

An old thread, but here's a large sample I put together years ago using Akka.Persistence.MongoDb + Clustering: https://github.com/Aaronontheweb/InMemoryCQRSReplication

Upvotes: 0

Bartosz Sypytkowski
Bartosz Sypytkowski

Reputation: 7542

Configuration requires providing fully qualified type names with assemblies. Try to specify class as "Akka.Persistence.MongoDb.Journal.MongoDbJournal, Akka.Persistence.MongoDb" (you probably don't need double quotes either, as it's not inline string).

Upvotes: 1

Related Questions