public async Task PublishAsync(Topic topic, MessageBody message) { ThrowIfDisposed(); await _firstConnectionTask.ConfigureAwait(false); List<NsqTcpConnection> connections; lock (_connections) { connections = _connections.Values.ToList(); } if (connections.Count == 0) throw new CommunicationException("No NSQ connections are available"); foreach (var thing in connections) { try { await thing.PublishAsync(topic, message).ConfigureAwait(false); return; } catch { continue; } } throw new CommunicationException("Write failed against all NSQ connections"); }
async Task PublishMessageAsync(NsqProducer producer, Topic topic, byte[] message) { await producer.PublishAsync(topic, message); StatusLabel.Text = "Published message: " + BitConverter.ToString(message); }
/// <summary> /// Publishes a message to NSQ. /// </summary> public Task PublishAsync(Topic topic, MessageBody message) { return SendCommandAsync(new Publish(topic, message)); }
public Subscribe(Topic topic, Channel channel) { _topic = topic; _channel = channel; }