| | | 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.Tasks; |
| | | 6 | | using CoreWCF.Queue.Common.Configuration; |
| | | 7 | | using Microsoft.Extensions.DependencyInjection; |
| | | 8 | | |
| | | 9 | | namespace CoreWCF.Queue.Common |
| | | 10 | | { |
| | | 11 | | internal class QueueProcessMessage |
| | | 12 | | { |
| | | 13 | | private readonly QueueMessageDispatcherDelegate _next; |
| | | 14 | | private readonly IServiceProvider _serviceProvider; |
| | | 15 | | |
| | 50 | 16 | | public QueueProcessMessage(QueueMessageDispatcherDelegate next, IServiceProvider serviceProvider) |
| | | 17 | | { |
| | 50 | 18 | | _next = next; |
| | 50 | 19 | | _serviceProvider = serviceProvider; |
| | 50 | 20 | | } |
| | | 21 | | |
| | | 22 | | public async Task InvokeAsync(QueueMessageContext queueMessageContext) |
| | | 23 | | { |
| | 1718 | 24 | | QueueInputChannel inputChannel = _serviceProvider.GetRequiredService<QueueInputChannel>(); |
| | 1718 | 25 | | inputChannel.LocalAddress = |
| | 1718 | 26 | | new EndpointAddress(queueMessageContext.QueueTransportContext.ServiceDispatcher.BaseAddress); |
| | 1718 | 27 | | var channelDispatcher = |
| | 1718 | 28 | | await queueMessageContext.QueueTransportContext.ServiceDispatcher.CreateServiceChannelDispatcherAsync( |
| | 1718 | 29 | | inputChannel); |
| | 1718 | 30 | | await channelDispatcher.DispatchAsync(queueMessageContext); |
| | 1718 | 31 | | } |
| | | 32 | | } |
| | | 33 | | } |