有没有一个Akka.net Persistence with MongoDb的工作示例?

时间:2016-04-15 16:26:57

标签: mongodb akka.net akka.net-persistence

我正在尝试将Akka.Net与日志持久性配置为MongoDb,但它正在抛出一个我无法理解的异常。 有没有一个参考示例,我可以看看它应该如何工作?我本来期望单元测试中的示例能够满足我的需要,但是缺少测试MongoDb执行持久化。 :(

这是我得到的错误:

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.

这是我的HOCON for this app: ---编辑 - 感谢提示Horusiath;基于我更新到这个HOCON和Sqlite提供程序,但MongoDb仍然出错。

  <![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>

所以,回到我原来的问题:是否有可以检查的MongoDb样本,以了解预期的工作原理

1 个答案:

答案 0 :(得分:1)

配置需要使用程序集提供完全限定的类型名称。尝试将类指定为class Post < ActiveRecord::Base has_many :comments, :order => "created_at DESC" validates :title, presence: true, length: { minimum: 5, maximum: 50 } validates :body, presence: true, length: { minimum: 20, maximum: 200 } end (您可能也不需要双引号,因为它不是内联字符串)。