static void Main(string[] args) { var config = ConfigurationFactory.ParseString(@" akka { actor { serializers { wire = ""Akka.Serialization.WireSerializer, Akka.Serialization.Wire"" } serialization-bindings { ""System.Object"" = wire } } } akka.persistence { publish-plugin-commands = on journal { plugin = ""akka.persistence.journal.eventstore"" eventstore { class = ""Akka.Persistence.EventStore.Journal.EventStoreJournal, Akka.Persistence.EventStore"" plugin-dispatcher = ""akka.actor.default-dispatcher"" host=""127.0.0.1"" tcp-port = ""1113"" } } }"); using (var system = ActorSystem.Create("AkkaEventStore", config)) { EventStorePersistence.Init(system); Start(system); ReadLine(); } }
public void Redis_JournalSettings_must_have_default_values() { var redisPersistence = EventStorePersistence.Get(Sys); redisPersistence.JournalSettings.ReadBatchSize.Should().Be(500); redisPersistence.JournalSettings.Adapter.Should().Be("default"); redisPersistence.JournalSettings.ConnectionName.Should().Be(string.Empty); }
private static void Main(string[] args) { ObjectContainer.SetContainer(new AutofacContainerObject()); var applictionInitializer = new EventHandleProvider(); applictionInitializer.Initialize(Assembly.GetExecutingAssembly()); var commandInitializer = new CommandHandleProvider(); commandInitializer.Initialize(Assembly.GetExecutingAssembly()); ObjectContainer.RegisterInstance(applictionInitializer); ObjectContainer.RegisterInstance(commandInitializer); var dbConnection = new MySqlConnection(_mysqlConnection); var persistence = new SnapshotPersistence(dbConnection); var binarySerializer = new DefaultBinarySerializer(); var snapshotRepository = new SnapshotRepository(persistence, new SnapshotFactory(binarySerializer)); var eventPersistence = new EventStorePersistence(dbConnection); var eventFactory = new EventStreamFactory(binarySerializer); var eventStore = new EventStore(eventPersistence, eventFactory); IRepository repository = new EventSouringRepository(eventStore, snapshotRepository); var comamndHandler = ObjectContainer.Resolve<CommandHandleProvider>(); var changePasswordCommand = new ChangePasswordCommand("90ca0d59-65e6-403b-82c5-8df967cc8e22", "2222222", "11111"); var commandContext = new CommandContext(repository); var commandHanldeAction = comamndHandler.GetInternalCommandHandle(typeof(ChangePasswordCommand)); commandHanldeAction(commandContext, changePasswordCommand); var aggregateRoots = commandContext.AggregateRoots; IList<IEvent> unCommitEvents = null; foreach (var item in aggregateRoots) { unCommitEvents = item.Value.Commit(); } var aggregateRoot = aggregateRoots.FirstOrDefault().Value; eventStore.AppendToStream(aggregateRoot.AggregateRootId, new EventStream(aggregateRoot.Version, unCommitEvents)); snapshotRepository.Create(aggregateRoot); Console.WriteLine("改方法执行完毕..."); }
public EventStoreJournal() { _settings = EventStorePersistence.Get(Context.System).JournalSettings; _log = Context.GetLogger(); var connectionString = _settings.ConnectionString; var connectionName = _settings.ConnectionName; _connRead = EventStoreConnection .Create(connectionString, $"{connectionName}.Read"); _connRead.ConnectAsync().Wait(); _conn = EventStoreConnection .Create(connectionString, connectionName); _conn.ConnectAsync() .PipeTo( Self, success: () => new Status.Success("Connected"), failure: ex => new Status.Failure(ex) ); _subscriptions = new EventStoreSubscriptions(_connRead, Context); }
public EventStoreSnapshotStore() { _settings = EventStorePersistence.Get(Context.System).SnapshotStoreSettings; _log = Context.GetLogger(); }
public EventStoreJournal() { _settings = EventStorePersistence.Get(Context.System).JournalSettings; _log = Context.GetLogger(); }
public TransactionStream() { _settings = EventStorePersistence.Get(Context.System).JournalSettings; _log = Context.GetLogger(); }