Hi Jonathan,
I have actually been playing with that very same scenario and just so happen to have a bit of code to share with you.
Let me know if this works for you?
public class Program
{
public static void Main()
{
var eventStore = StartEmbeddedEventStore();
var defaultCredentials = new UserCredentials(“admin”, “changeit”);
var connectionSettings = ConnectionSettings.Create()
.SetDefaultUserCredentials(null) //replace with
//.SetDefaultUserCredentials(defaultCredentials)
.KeepReconnecting();
using (var connection = EmbeddedEventStoreConnection.Create(eventStore, connectionSettings))
{
connection.ConnectAsync().Wait();
var sub = connection.SubscribeToStreamFrom("$ce-test", null, true,
(_, evt) => Console.WriteLine(“Event Appeared: {0}”, evt.Event.EventType),
subscriptionDropped: (_, reason, e) => Console.WriteLine(“Subscription Dropped, Reason : {0}/{1}”, reason, e.InnerException.Message),
userCredentials: null);
//userCredentials: defaultCredentials);
connection.AppendToStreamAsync(“test-account”,
ExpectedVersion.Any,
GetEventDataFor(100)).Wait();
Console.WriteLine("-------------------------------");
Console.WriteLine(“Embedded Event Store is now running with Projections Enabled.”);
Console.WriteLine(“You are able to issue a curl request to http://localhost:2113/stats as well as http://localhost:2113/projections/any”);
Console.WriteLine();
Console.WriteLine(“Press any key to kill the node.”);
Console.WriteLine("-------------------------------");
Console.ReadLine();
sub.Stop();
connection.Close();
}
eventStore.Stop();
}
static ClusterVNode StartEmbeddedEventStore()
{
var embeddedEventStore = EmbeddedVNodeBuilder.AsSingleNode()
.RunInMemory()
.RunProjections(ProjectionsMode.All)
.OnDefaultEndpoints()
.StartStandardProjections()
.AddExternalHttpPrefix(“http://*:2113/”)
.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;
}
private static EventData GetEventDataFor(int i)
{
return new EventData(
Guid.NewGuid(),
“DepositMade”,
true,
Encoding.ASCII.GetBytes("{“somedata” : " + i + “}”),
Encoding.ASCII.GetBytes("{“metadata” : " + i + “}”)
);
}
}
``