每次我在Akka.NET中创建一个新的类型对象。该类型的整个Journal将在构造函数
中加载我的测试:
[Test, Category("Integration")]
public async Task Should_Persist_Actor()
{
var model = Mocks.Fake.Contact();
await Actors.ContactActor.Ask(new CreateContactCommand(model, "unit test", DateTime.Now));
var context = new MyTestContext("xxx");
using (context)
{
var found = context.Set<Contact>().FirstOrDefault(x => x.Id == model.Id);
Assert.IsNotNull(found);
}
}
这是一个持续受到攻击的构造函数,对于日记中的每个条目都是
public sealed class CreateContactCommand : AuditCommandBase<Contact, CreateContactEvent>, ICommand<Contact, CreateContactEvent>
{
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
public CreateContactCommand(Contact obj, string auditUser, DateTime auditTime) : base(obj, auditUser, auditTime)
{
// This gets hit for everything in the journal db
_logger.Debug("Create Contact Command Ctor");
}
}
如果我截断日记,我的测试立即通过。如果日志中有数据,则会触及每个项目的类型构造函数...
答案 0 :(得分:0)
这是按预期工作的。当你将akka演员带到网上时,它将通过重播事件日志来恢复它的状态。