Ejemplo n.º 1
0
        public Task <MessageResponse[]> SendAsync(CancellationToken sendCancellationToken, params IMessage[] events)
        {
            var sendTaskCompletionSource = new TaskCompletionSource <MessageResponse>();

            if (sendCancellationToken != CancellationToken.None)
            {
                sendCancellationToken.Register(OnSendCancel, sendTaskCompletionSource);
            }

            var messageStates = events.Select(message =>
            {
                var topic = message.GetFormatTopic();
                return(new MessageState(_messageQueueClient.WarpMessage(message, topic: topic, key: message.Key),
                                        sendTaskCompletionSource, false));
            }).ToArray();

            return(SendAsync(messageStates));
        }