private async void RunListener(string route, CancellationToken cancellationToken) { try { _unprocessedMessagesResender.Start(route, _messagingConfiguration.ResendInterval, cancellationToken); while (true) { try { await _listeningAgent.Listen(route, cancellationToken); } catch (TaskCanceledException) { _messagingLogger.Info($"{route} cancelled listener"); return; } catch (Exception e) { _messagingLogger.Error(e, $"error on listening in {route}, trying againg"); } await Task.Delay(500, cancellationToken); } } catch (Exception e) { _messagingLogger.Error(e, $"error on starting listening in {route}, listener is stopped"); } }
private async Task TryHandleAsync(TEvent eventToHandle, Func <Task> receiver) { _logger.Info($"Handling event {eventToHandle}"); await receiver(); }