public async Task <MqMessage> AddMessage(MqCreateMessage message, CancellationToken cancellationToken = default)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            Guid id = await this.EndshureQueuId(cancellationToken).ConfigureAwait(false);

            using (Microsoft.Rest.HttpOperationResponse <object> response = await this.passiveMqApi.CreateMessageWithHttpMessagesAsync(id, message.ToDto(), null, cancellationToken).ConfigureAwait(false))
            {
                Models.MessageDto dto = response.AsResult <Models.MessageDto>();
                return(MqMessage.FromDto(dto));
            }
        }
Example #2
0
        public async Task Publish(string topic, MqCreateMessage message, CancellationToken cancellationToken = default)
        {
            if (topic == null) throw new ArgumentNullException(nameof(topic));
            if (message == null) throw new ArgumentNullException(nameof(message));

            Models.MessagePublishDto dto = new Models.MessagePublishDto()
            {
                Message = message.ToDto(),
                Topic = topic.Trim()
            };

            using (Microsoft.Rest.HttpOperationResponse<object> respone = await this.passiveMqApi.PublishWithHttpMessagesAsync(dto, null, cancellationToken).ConfigureAwait(false))
            {
                respone.AsResult();
            }
        }