-
-
Save mbp/a8d7625ba280b10016e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net; | |
using EventStore.ClientAPI; | |
using EventStore.ClientAPI.SystemData; | |
namespace EventStoreProblem | |
{ | |
class Program | |
{ | |
private static int _eventCount = 0; | |
static void Main(string[] args) | |
{ | |
var connectionSettings = | |
ConnectionSettings.Create() | |
.UseConsoleLogger() | |
.SetDefaultUserCredentials(new UserCredentials("admin", "changeit")) | |
.KeepReconnecting() | |
.OnReconnecting(OnReconnecting) | |
.OnDisconnected(OnDisconnected) | |
.OnConnected(OnConnected) | |
.OnErrorOccurred(OnErrorOccured) | |
.OnAuthenticationFailed(LogAuthenticationFailed) | |
.OnClosed(OnClosed); | |
var eventStoreConnection = EventStoreConnection.Create(connectionSettings, GetIpEndPoint()); | |
eventStoreConnection.Connect(); | |
eventStoreConnection.SubscribeToAllFrom(null, false, EventAppeared, LiveProcessingStarted, SubscriptionDropped); | |
Console.ReadLine(); | |
} | |
private static IPEndPoint GetIpEndPoint() | |
{ | |
var ipAddress = IPAddress.Parse("127.0.0.1"); | |
return new IPEndPoint(ipAddress, 1113); | |
} | |
private static void SubscriptionDropped(EventStoreCatchUpSubscription arg1, SubscriptionDropReason arg2, Exception arg3) | |
{ | |
Console.WriteLine("SubscriptionDropped"); | |
} | |
private static void EventAppeared(EventStoreCatchUpSubscription arg1, ResolvedEvent arg2) | |
{ | |
Console.WriteLine("EventAppeared {0}", _eventCount++); | |
} | |
private static void LiveProcessingStarted(EventStoreCatchUpSubscription obj) | |
{ | |
Console.WriteLine("LiveProcessingStarted"); | |
} | |
private static void OnClosed(IEventStoreConnection arg1, string arg2) | |
{ | |
Console.WriteLine("OnClosed"); | |
} | |
private static void LogAuthenticationFailed(IEventStoreConnection arg1, string arg2) | |
{ | |
Console.WriteLine("LogAuthenticationFailed"); | |
} | |
private static void OnErrorOccured(IEventStoreConnection arg1, Exception arg2) | |
{ | |
Console.WriteLine("OnErrorOccured"); | |
} | |
private static void OnConnected(IEventStoreConnection arg1, IPEndPoint arg2) | |
{ | |
Console.WriteLine("OnConnected"); | |
} | |
private static void OnDisconnected(IEventStoreConnection arg1, IPEndPoint arg2) | |
{ | |
Console.WriteLine("OnDisconnected"); | |
} | |
private static void OnReconnecting(IEventStoreConnection obj) | |
{ | |
Console.WriteLine("OnReconnecting"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: