private void ListenMessages(CancellationToken token, Barrier gateway) { try { using (clusterMonitorSubscriptionSocket = CreateClusterMonitorSubscriptionSocket()) { using (var routerNotificationSocket = CreateRouterCommunicationSocket()) { gateway.SignalAndWait(token); while (!token.IsCancellationRequested) { var message = clusterMonitorSubscriptionSocket.ReceiveMessage(token); if (message != null) { ProcessIncomingMessage(message, routerNotificationSocket); } } } } } catch (Exception err) { logger.Error(err); } }