| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Threading; |
| | | 6 | | using System.Threading.Tasks; |
| | | 7 | | using CoreWCF.Queue.Common; |
| | | 8 | | |
| | | 9 | | namespace CoreWCF.Channels |
| | | 10 | | { |
| | | 11 | | internal class MsmqReceiveContext : ReceiveContext |
| | | 12 | | { |
| | | 13 | | private readonly QueueMessageContext _queueMessageContext; |
| | | 14 | | private readonly DeadLetterQueueSender _deadLetterQueueSender; |
| | | 15 | | |
| | 0 | 16 | | public MsmqReceiveContext(QueueMessageContext queueMessageContext, DeadLetterQueueSender deadLetterQueueSender) |
| | | 17 | | { |
| | 0 | 18 | | _queueMessageContext = queueMessageContext; |
| | 0 | 19 | | _deadLetterQueueSender = deadLetterQueueSender; |
| | 0 | 20 | | } |
| | | 21 | | |
| | | 22 | | protected override async Task OnAbandonAsync(CancellationToken token) |
| | | 23 | | { |
| | 0 | 24 | | if (_queueMessageContext.QueueTransportContext.ServiceDispatcher.Binding is NetMsmqBinding binding && |
| | 0 | 25 | | binding.DeadLetterQueue == DeadLetterQueue.Custom) |
| | | 26 | | { |
| | 0 | 27 | | await _deadLetterQueueSender.Send(_queueMessageContext.QueueMessageReader, binding.CustomDeadLetterQueue |
| | | 28 | | } |
| | | 29 | | else |
| | | 30 | | { |
| | 0 | 31 | | await _deadLetterQueueSender.SendToSystem(_queueMessageContext.QueueMessageReader, _queueMessageContext. |
| | | 32 | | } |
| | 0 | 33 | | } |
| | | 34 | | |
| | | 35 | | protected override async Task OnCompleteAsync(CancellationToken token) |
| | 0 | 36 | | { |
| | | 37 | | // Do nothing |
| | 0 | 38 | | } |
| | | 39 | | } |
| | | 40 | | } |