public async Task <IReadOnlyList <IQueueMessage <T> > > GetAsync(int take, TimeSpan?lockTime) { var request = new RecieveMessagesRequest(take, lockTime); return((await client.ReceiveMessagesAsync(url, request).ConfigureAwait(false)) .Select(m => (IQueueMessage <T>) new JsonEncodedMessage <T>(m)) .ToList()); }
public async Task <IReadOnlyList <IQueueMessage <T> > > GetAsync(int take, TimeSpan?lockTime) { var request = new RecieveMessagesRequest(take, lockTime); var result = await client.ReceiveMessagesAsync(url, request).ConfigureAwait(false); return(Convert(result)); }
public async Task <SqsMessage[]> ReceiveMessagesAsync(Uri queueUrl, RecieveMessagesRequest request) { if (request is null) { throw new ArgumentNullException(nameof(request)); } var httpRequest = new HttpRequestMessage(HttpMethod.Post, queueUrl) { Content = GetPostContent(request.ToParams()) }; string responseText = await SendAsync(httpRequest).ConfigureAwait(false); var response = ReceiveMessageResponse.Parse(responseText); return(response.ReceiveMessageResult.Items ?? Array.Empty <SqsMessage>()); }
public async Task <SqsMessage[]> ReceiveMessagesAsync(Uri queueUrl, RecieveMessagesRequest request) { #region Preconditions if (request == null) { throw new ArgumentNullException(nameof(request)); } #endregion var httpRequest = new HttpRequestMessage(HttpMethod.Post, queueUrl) { Content = GetPostContent(request.ToParams()) }; var responseText = await SendAsync(httpRequest).ConfigureAwait(false); return(RecieveMessageResponse.Parse(responseText).ToArray()); }
public async Task <IReadOnlyList <IQueueMessage <string> > > PollAsync( int take, TimeSpan?lockTime, CancellationToken cancellationToken = default) { // Blocks until we recieve a message var request = new RecieveMessagesRequest(take, lockTime, TimeSpan.FromSeconds(20)); while (!cancellationToken.IsCancellationRequested) { var result = await client.ReceiveMessagesAsync(url, request).ConfigureAwait(false); if (result.Length > 0) { return(result); } } return(Array.Empty <IQueueMessage <string> >()); }