/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/MassTransit/Middleware/SetRoutingKeyFilter.cs
33 строки
980 B
Chris Patterson
Refactored RoutingKey send topology formatter into the main assembly (used by gRPC and RabbitMQ, also the Database Transport)
16 июл 2023, 15:43
16 июл 2023, 15:43
62a1596
Код
Авторство
О чём код?
namespace MassTransit.Middleware { using System.Threading.Tasks; using Transports; public class SetRoutingKeyFilter<TMessage> : IFilter<SendContext<TMessage>> where TMessage : class { readonly IMessageRoutingKeyFormatter<TMessage> _routingKeyFormatter; public SetRoutingKeyFilter(IMessageRoutingKeyFormatter<TMessage> routingKeyFormatter) { _routingKeyFormatter = routingKeyFormatter; } public Task Send(SendContext<TMessage> context, IPipe<SendContext<TMessage>> next) { var routingKey = _routingKeyFormatter.FormatRoutingKey(context); if (context.TryGetPayload(out RoutingKeySendContext routingKeySendContext)) routingKeySendContext.RoutingKey = routingKey; return next.Send(context); } public void Probe(ProbeContext context) { context.CreateFilterScope("setRoutingKey"); } } }