-
What does the server do when we send PersistentSubscriptionNakEventAction.Unknown?
-
We are using Competing consumers and we enable keep reconnecting option when we create a connection. However, if the event store is shutdown, it throws a connection closed exception. When event store comes up, the connection is not reestablished. Is this the expected workflow or am I doing something wrong? What is the best practice to reconnect (add a retry logic inside OnSubscriptionDropped??)?
Code:
try
{
var credentials = new EventStore.ClientAPI.SystemData.UserCredentials(“admin”, “changeit”);
var settings = PersistentSubscriptionSettings
.Create()
.Build();
var connsettings = ConnectionSettings.Create().SetDefaultUserCredentials(credentials);
connsettings = connsettings.KeepReconnecting().KeepRetrying();
var endpoint = new System.Net.IPEndPoint(System.Net.IPAddress.Loopback.Address, 1113);
using (var conn = EventStoreConnection.Create(connsettings, endpoint))
{
conn.ConnectAsync().Wait();
conn.CreatePersistentSubscriptionAsync(“test-stream”, “test-group”, settings, credentials);
conn.ConnectToPersistentSubscriptionAsync(“test-stream”, “test-group”,
(subscriber, evt) =>
{
try
{
Console.WriteLine(“Here-Read event with data: {0}”,
Encoding.UTF8.GetString(evt.Event.Data));
subscriber.Acknowledge(evt);
}
catch (Exception e)
{
subscriber.Fail(evt, PersistentSubscriptionNakEventAction.Park, “Try again”);
Console.WriteLine(e.ToString());
}
},
(subscriber, reason, exception) => {
Console.WriteLine(exception.ToString());
},
userCredentials:credentials,
autoAck: false);
Console.WriteLine(“Waiting”);
Console.ReadKey();
}