In the dispatcher, There are following three methods,
public void Start()
{
Restart();
}
public void Stop()
{
try
{
logger.Info(“Stopping service…”);
if (catchUpSubscription != null && catchUpSubscription.IsSubscribedToAll)
{
catchUpSubscription.Stop(TimeSpan.FromSeconds(10));
}
logger.Info(“Service stopped.”);
}
catch (TimeoutException exception)
{
logger.Error(exception);
}
}
private void Restart()
{
lastPosition = PreparePosition(tracker.GetPosition());
logger.InfoFormat(“Starting subscription from:{0}”, lastPosition);
catchUpSubscription = connection.SubscribeToAllFrom(
lastPosition,
false,
EventAppeared,
null,
SubscriptionDropped);
}
``
This dispatcher is a part of a windows service developed using TopShelf.
On starting the windows service, it calls the start method and the dispatcher starts dispatching events.
When the windows service is stopped, it calls the Stop method on the dispatcher that throws following error:
Stopping service…
System.TimeoutException: Couldn’t stop EventStoreAllCatchUpSubscription in time.
at EventStore.ClientAPI.EventStoreCatchUpSubscription.Stop(TimeSpan timeout)
at EventDispatcherService.EventDispatcher.Stop()
System.TimeoutException: Couldn’t stop EventStoreAllCatchUpSubscription in time.
at EventStore.ClientAPI.EventStoreCatchUpSubscription.Stop(TimeSpan timeout)
at EventDispatcherService.EventDispatcher.Stop()
Even after increasing the timeout period, it does not stop the subscription, rather it times out each time.
What is wrong with the code? why the subscription does not stop normally?, I am using V2.0.2.0 of the eventstoreclient API.