Good day all. I can’t seem to get the catchup subscription with embedded event store to work properly. Grabbed the latest embedded event store from nuget this morning.
Here’s a basic reproduction… should be seeing " Live Event Appeared" every 1 second in the console. I see the Non-Live events and the Live message, but after Live… nothing…
namespace esbug1
{
using EventStore.ClientAPI;
using EventStore.ClientAPI.Embedded;
using EventStore.Core;
using EventStore.Core.Bus;
using EventStore.Core.Messages;
using System;
using System.Net;
using System.Threading;
class Program
{
static void Main(string[] args)
{
bool islive = false;
var path = @"C:\Users\cray\Desktop\db\";
var node = StartEmbeddedEventStore(path);
var conn = EmbeddedEventStoreConnection.Create(node, ConnectionSettings.Create().LimitRetriesForOperationTo(3));
var sub = conn.SubscribeToAllFrom(Position.Start, false,
(s, ev) => Console.WriteLine(islive ? $"Live" : "Non-Live" + " Event Appeared"),
(s) => { islive = true; Console.WriteLine("Live!!"); },
(s, e, ex) => Console.WriteLine("Subscription Dropped."),
new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit"));
while (true)
{
Write("foo", "FooEvent", "{bla:1}", conn);
Thread.Sleep(1000);
}
}
static ClusterVNode StartEmbeddedEventStore(string path)
{
var embeddedEventStore = EmbeddedVNodeBuilder.AsSingleNode()
.RunOnDisk(path)
.RunProjections(ProjectionsMode.All)
.WithExternalTcpOn(new IPEndPoint(IPAddress.Loopback, 1234))
.WithInternalTcpOn(new IPEndPoint(IPAddress.None, 1234))
.WithInternalHttpOn(new IPEndPoint(IPAddress.None, 1234))
.WithExternalHttpOn(new IPEndPoint(IPAddress.Loopback, 1234))
.Build();
var startedEvent = new ManualResetEventSlim(false);
embeddedEventStore.MainBus.Subscribe(new AdHocHandler<UserManagementMessage.UserManagementServiceInitialized>(m => startedEvent.Set()));
embeddedEventStore.Start();
if (!startedEvent.Wait(60000))
throw new TimeoutException("Embedded Event Store has not started in 60 seconds.");
return embeddedEventStore;
}
static void Write(string streamName, string eventType, string text, IEventStoreConnection conn) =>
conn.AppendToStreamAsync(streamName, ExpectedVersion.Any, new EventData(Guid.NewGuid(), eventType, true, System.Text.Encoding.UTF8.GetBytes(text), null)).Wait();
}
}
``