async Task DisposeMessageRequestResponseAsync(IEnumerable <Guid> lockTokens, DispositionStatus dispositionStatus) { try { // Create an AmqpRequest Message to update disposition AmqpRequestMessage requestMessage = AmqpRequestMessage.CreateRequest(ManagementConstants.Operations.UpdateDispositionOperation, this.OperationTimeout, null); requestMessage.Map[ManagementConstants.Properties.LockTokens] = lockTokens.ToArray(); requestMessage.Map[ManagementConstants.Properties.DispositionStatus] = dispositionStatus.ToString().ToLowerInvariant(); await this.ExecuteRequestResponseAsync(requestMessage); } catch (AmqpException amqpException) { throw AmqpExceptionHelper.ToMessagingContract(amqpException.Error); } }
async Task DisposeMessageRequestResponseAsync(IEnumerable <Guid> lockTokens, DispositionStatus dispositionStatus) { try { // Create an AmqpRequest Message to update disposition AmqpRequestMessage requestMessage = AmqpRequestMessage.CreateRequest(ManagementConstants.Operations.UpdateDispositionOperation, this.OperationTimeout, null); requestMessage.Map[ManagementConstants.Properties.LockTokens] = lockTokens.ToArray(); requestMessage.Map[ManagementConstants.Properties.DispositionStatus] = dispositionStatus.ToString().ToLowerInvariant(); AmqpResponseMessage amqpResponseMessage = await this.ExecuteRequestResponseAsync(requestMessage).ConfigureAwait(false); if (amqpResponseMessage.StatusCode != AmqpResponseStatusCode.OK) { throw amqpResponseMessage.ToMessagingContractException(); } } catch (Exception exception) { throw AmqpExceptionHelper.GetClientException(exception); } }
/// <summary> /// Updates the disposition status of deferred messages. /// </summary> /// /// <param name="lockTokens">Message lock tokens to update disposition status.</param> /// <param name="timeout"></param> /// <param name="dispositionStatus"></param> /// <param name="isSessionReceiver"></param> /// <param name="sessionId"></param> /// <param name="receiveLinkName"></param> /// <param name="propertiesToModify"></param> /// <param name="deadLetterReason"></param> /// <param name="deadLetterDescription"></param> internal override async Task DisposeMessageRequestResponseAsync( Guid[] lockTokens, TimeSpan timeout, DispositionStatus dispositionStatus, bool isSessionReceiver, string sessionId = null, string receiveLinkName = null, IDictionary <string, object> propertiesToModify = null, string deadLetterReason = null, string deadLetterDescription = null) { try { // Create an AmqpRequest Message to update disposition var amqpRequestMessage = AmqpRequestMessage.CreateRequest(ManagementConstants.Operations.UpdateDispositionOperation, timeout, null); if (receiveLinkName != null) { amqpRequestMessage.AmqpMessage.ApplicationProperties.Map[ManagementConstants.Request.AssociatedLinkName] = receiveLinkName; } amqpRequestMessage.Map[ManagementConstants.Properties.LockTokens] = lockTokens; amqpRequestMessage.Map[ManagementConstants.Properties.DispositionStatus] = dispositionStatus.ToString().ToLowerInvariant(); if (deadLetterReason != null) { amqpRequestMessage.Map[ManagementConstants.Properties.DeadLetterReason] = deadLetterReason; } if (deadLetterDescription != null) { amqpRequestMessage.Map[ManagementConstants.Properties.DeadLetterDescription] = deadLetterDescription; } if (propertiesToModify != null) { var amqpPropertiesToModify = new AmqpMap(); foreach (var pair in propertiesToModify) { if (AmqpMessageConverter.TryGetAmqpObjectFromNetObject(pair.Value, MappingType.ApplicationProperty, out var amqpObject)) { amqpPropertiesToModify[new MapKey(pair.Key)] = amqpObject; } else { throw new NotSupportedException( Resources.InvalidAmqpMessageProperty.FormatForUser(pair.Key.GetType())); } } if (amqpPropertiesToModify.Count > 0) { amqpRequestMessage.Map[ManagementConstants.Properties.PropertiesToModify] = amqpPropertiesToModify; } } if (!string.IsNullOrWhiteSpace(sessionId)) { amqpRequestMessage.Map[ManagementConstants.Properties.SessionId] = sessionId; } if (isSessionReceiver) { // TODO - ThrowIfSessionLockLost(); } var amqpResponseMessage = await ExecuteRequestResponseAsync(amqpRequestMessage, timeout).ConfigureAwait(false); if (amqpResponseMessage.StatusCode != AmqpResponseStatusCode.OK) { // throw amqpResponseMessage.ToMessagingContractException(); } } catch (Exception) { // throw AmqpExceptionHelper.GetClientException(exception); throw; } }