Ejemplo n.º 1
0
 /// <summary>
 /// Publishes a message to NSQ.
 /// </summary>
 public Task PublishAsync(Topic topic, MessageBody message)
 {
     return SendCommandAsync(new Publish(topic, message));
 }
Ejemplo n.º 2
0
        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");
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Publishes a message to NSQ.
 /// </summary>
 public Task PublishAsync(Topic topic, MessageBody message)
 {
     return(SendCommandAsync(new Publish(topic, message)));
 }