internal void SendMessages(string url, string clusterID) { IStanConnection sc = null; sc = CreateConnection(url, clusterID, "synadia-rel-publisher"); for (int i = 0; !IsFinished(); i++) { try { sc.Publish("synadia.restest", payload, (obj, args) => { /* NOOP */ }); // sync publish for long running stability // sc.Publish("synadia.restest", payload); ; } catch (Exception e) { Log("Publish Exception: " + e.Message); Thread.Sleep(250); } if (i % 500 == 0) { Log("Publisher Sent {0} messages to the streaming server.", i); PrintResourceStats(); } } sc?.Close(); Log("Publisher is finished."); }
public void Stop() { _cancellationTokenSource.Cancel(); _subscription.Close(); _connection.Close(); _storingData.Close(); }
internal void ProcessMsgs(string url, string clusterID) { IStanConnection sc = null; try { sc = CreateConnection(url, clusterID, "synadia-rel-sub"); var opts = StanSubscriptionOptions.GetDefaultOptions(); opts.AckWait = 60000; opts.ManualAcks = true; opts.MaxInflight = 32; opts.DurableName = "synadia-restest"; sc.Subscribe("synadia.restest", "qg", opts, ProcessMsg); FeV.WaitOne(); } catch (Exception e) { Log("Create Subscriber failed: " + e); } finally { sc?.Close(); } Log("Subscriber is finished."); }
protected void cleanup() { if (sOpts.DurableName != null && unsubscribe) { s?.Unsubscribe(); } c?.Close(); }
private void CloseAndDisposeStan() { if (stanConnection != null) { stanConnection.Close(); stanConnection.Dispose(); } }
public void close() { if (dicSubscription.Count > 0) { foreach (var keyPair in dicSubscription) { keyPair.Value.Close(); } } conn?.Close(); }
public Task StopAsync(CancellationToken cancellationToken) { if (!stoppedValue) { if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation($"Stopping hosted service \"{nameof(StanMessageReceiverService)}\"."); } try { _cancellationTokenSource?.Cancel(); if (_tasks != null) { try { Task.WaitAll(_tasks, 5000); } catch (AggregateException) { } } _connection?.Close(); _connection?.Dispose(); stoppedValue = true; if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation($"Stopped hosted service \"{nameof(StanMessageReceiverService)}\"."); } } catch (Exception e) { if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation($"Stopping hosted service \"{nameof(StanMessageReceiverService)}\" throws exception. {e.Message}"); } throw e; } } return(Task.CompletedTask); }
public void Stop() { _repo.Close(); _natsConnection.Close(); _stanConnection.Close(); }
public void Stop() { _cancellationTokenSource.Cancel(); _connection.Close(); }
public void CloseConnection() { _stanConnection.Close(); }
public void Dispose() { _connection.Close(); _connection?.Dispose(); }
public void Stop() { _stanConnection.Close(); }