我想知道是否有可能通过Get Event Store
创建订阅服务Mongo
?也许我误解了这句话,但让我解释一下。我目前有一个使用NEventStore
将事件写入Mongo Database
的过程。我想要做的是订阅Stream
Mongo
订阅服务。Event Store订阅服务MongoDB
无法在interweb上找到任何关于此的内容,但这是可能的吗?简而言之,我的问题可能是你可以将两者混合在一起,或者为了做到这一点,我必须将我的活动写入eventstore
而不是Mongo
?也许,我正在谈论这个错误,并且有另一种选择?
我可以看到我正在编写的事件,但无法触发EventAppeared
。所有这些都是在我的机器上进行的。
我试图创建一个精简的应用程序,它做到这一点:
使用以下
using (var connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113))) { connection.SubscribeToStreamAsync(@"mongodb://localhost:27017/Test", false, EventAppeared, SubscriptionDropped); var repository = new NEventStoreRepository(); repository.Write(new SomethingHasHappened("Hello")); Console.ReadLine(); } private static void SubscriptionDropped(EventStoreSubscription arg1, SubscriptionDropReason arg2, Exception arg3) { } private static void EventAppeared(EventStoreSubscription arg1, ResolvedEvent arg2) { }
我通过NEventStore将事件写入我的蒙戈数据库
创建订阅public void Write(object @event) { var id = Guid.NewGuid(); using (var scope = new TransactionScope()) { using (var store = WireupEventStore()) { using (var stream = store.OpenStream(id.ToString(), 0, int.MaxValue)) { stream.Add(new EventMessage { Body = @event }); stream.CommitChanges(Guid.NewGuid()); scope.Complete(); } } } Console.ReadKey(); } private static IStoreEvents WireupEventStore() { return Wireup .Init() .LogToOutputWindow() .UsingMongoPersistence("NEventStore.MongoDB", new DocumentObjectSerializer()) .InitializeStorageEngine() .UsingJsonSerialization() .Build(); }
你在说GetEventStore吗? – tomliversidge
道歉,是的。 –
您已将您的mongodb连接作为GetEventStore中事件流的名称。这是故意的吗?您的流实际上是否称为“mongodb:// localhost:27017/Test”? – tomliversidge