/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/MassTransit.Abstractions/Contexts/RoutingKeyExtensions.cs
44 строки
1 KB
Chris Patterson
Merging the SQL transport into the main codebase
09 янв 2024, 05:23
09 янв 2024, 05:23
e1eb39e
Код
Авторство
О чём код?
namespace MassTransit; using System; public static class RoutingKeyExtensions { public static string? RoutingKey(this ConsumeContext context) { return context.TryGetPayload(out RoutingKeyConsumeContext? consumeContext) ? consumeContext.RoutingKey : string.Empty; } public static string? RoutingKey(this SendContext context) { return context.TryGetPayload(out RoutingKeySendContext? sendContext) ? sendContext.RoutingKey : string.Empty; } /// <summary> /// Sets the routing key for this message /// </summary> /// <param name="context"></param> /// <param name="routingKey">The routing key for this message</param> public static void SetRoutingKey(this SendContext context, string? routingKey) { if (!context.TryGetPayload(out RoutingKeySendContext? sendContext)) throw new ArgumentException("The SendRoutingKeyContext was not available"); sendContext.RoutingKey = routingKey; } /// <summary> /// Sets the routing key for this message /// </summary> /// <param name="context"></param> /// <param name="routingKey">The routing key for this message</param> public static bool TrySetRoutingKey(this SendContext context, string? routingKey) { if (!context.TryGetPayload(out RoutingKeySendContext? sendContext)) return false; sendContext.RoutingKey = routingKey; return true; } }