1

你能帮忙吗?保存一两次时效果很好。三个或更多,我得到这个:

    [INFO][11/28/2017 2:57:27 PM][Thread 0005][[akka://ECHO3DEV/user/api-master/PortfolioCoordinator/TK#425630680]] Portfolio Actor: TK completely recovered. Current Positions: ......
11/28/2017 9:57:27 AM portfolio- Actor started...
[ERROR][11/28/2017 2:57:27 PM][Thread 0005][[akka://ECHO3DEV/user/api-master/PortfolioCoordinator/TK/TK-IBM#1280277591]] **Persistence failure when replaying events for persistenceId [portfolio-TK-IBM]. **Last known sequence number [3]
Cause: System.NotSupportedException: Generic IDictionary<TKey,TValue> are not yet supported****
   at Hyperion.SerializerFactories.DictionarySerializerFactory.<>c__DisplayClass3_0.<BuildSerializer>b__0(Stream stream, DeserializerSession session)
   at Hyperion.ValueSerializers.ObjectSerializer.ReadValue(Stream stream, DeserializerSession session)
   at lambda_method(Closure , Stream , DeserializerSession )
   at Hyperion.ValueSerializers.ObjectSerializer.ReadValue(Stream stream, DeserializerSession session)
   at lambda_method(Closure , Stream , DeserializerSession )
   at Hyperion.ValueSerializers.ObjectSerializer.ReadValue(Stream stream, DeserializerSession session)
   at lambda_method(Closure , Stream , DeserializerSession )
   at Hyperion.ValueSerializers.ObjectSerializer.ReadValue(Stream stream, DeserializerSession session)
   at Hyperion.SerializerFactories.DefaultDictionarySerializerFactory.<>c__DisplayClass3_0.<BuildSerializer>b__0(Stream stream, DeserializerSession session)
   at Hyperion.ValueSerializers.ObjectSerializer.ReadValue(Stream stream, DeserializerSession session)
   at lambda_method(Closure , Stream , DeserializerSession )
   at Hyperion.ValueSerializers.ObjectSerializer.ReadValue(Stream stream, DeserializerSession session)
   at lambda_method(Closure , Stream , DeserializerSession )
   at Hyperion.ValueSerializers.ObjectSerializer.ReadValue(Stream stream, DeserializerSession session)
   at Hyperion.Serializer.Deserialize[T](Stream stream)
   at Akka.Serialization.HyperionSerializer.FromBinary(Byte[] bytes, Type type)
   at Akka.Persistence.Sql.Common.Journal.AbstractQueryExecutor.ReadEvent(DbDataReader reader)
   at Akka.Persistence.Sql.Common.Journal.AbstractQueryExecutor.<SelectByPersistenceIdAsync>d__44.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Akka.Persistence.Sql.Common.Journal.SqlJournal.<ReplayMessagesAsync>d__32.MoveNext()

我该如何调试呢?

4

1 回答 1

1

这不是 Akka.Persistence 本身的问题。该错误本身位于 Hyperion 序列化程序中,您不应该将其用于持久性(仅用于远程处理)。毕竟,你要存储的数据是你的,如果你能控制自己如何存储它会更好;)

我在这里描述了这个和其他常见的 Akka.Persistence 错误。

反对使用 Hyperion 进行持久性的原因之一是它仍处于测试阶段,并且它的二进制格式不是一成不变的。这意味着在升级序列化程序后,您可能无法再读回您的事件。

出于这个原因,最好为您的事件显式定义具有众所周知的模式的序列化程序。您可以决定自己推出,或者选择MsqPackMicrosoft Bond - 它们使用显式模式定义,随着时间的推移和事件内容的变化,使其更容易工作。

要定义自定义序列化程序,您需要使用某种类型(即空接口)标记事件,您将使用它来识别哪个序列化程序适用于它们。然后只需在 HOCON 配置中定义一个序列化器映射:

akka.actor {  
  serializers.msgpack= "Akka.Serialization.MessagePack.MsgPackSerializer, Akka.Serialization.MessagePack"
  serialization-bindings {
    "MyNamespace.IDomainEvent, MyAssembly" = msgpack
  }
}

在这里,我使用 Akka.NET MsgPack 序列化程序来自定义接口IDomainEvent,我将通过它来识别我的事件。类型识别需要带有程序集的完全限定类型名称。

于 2017-11-28T19:05:15.353 回答