/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/MassTransit/Configuration/CorrelationIdConventionExtensions.cs
88 строк
4 KB
Chris Patterson
Integration of all external packages into MassTransit, split out into Abstractions, Middleware, and the core MassTransit assembly.
22 янв 2022, 18:24
22 янв 2022, 18:24
b5b4f50
Код
Авторство
О чём код?
namespace MassTransit { using System; using Configuration; using Topology; public static class CorrelationIdConventionExtensions { /// <summary> /// Specify for the message type that the delegate be used for setting the CorrelationId /// property of the message envelope. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="configurator"></param> /// <param name="correlationIdSelector"></param> public static void UseCorrelationId<T>(this IMessageSendTopologyConfigurator<T> configurator, Func<T, Guid> correlationIdSelector) where T : class { configurator.AddOrUpdateConvention<ICorrelationIdMessageSendTopologyConvention<T>>( () => { var convention = new CorrelationIdMessageSendTopologyConvention<T>(); convention.SetCorrelationId(new DelegateMessageCorrelationId<T>(correlationIdSelector)); return convention; }, update => { update.SetCorrelationId(new DelegateMessageCorrelationId<T>(correlationIdSelector)); return update; }); } /// <summary> /// Specify for the message type that the delegate be used for setting the CorrelationId /// property of the message envelope. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="configurator"></param> /// <param name="correlationIdSelector"></param> public static void UseCorrelationId<T>(this IMessageSendTopologyConfigurator<T> configurator, Func<T, Guid?> correlationIdSelector) where T : class { configurator.AddOrUpdateConvention<ICorrelationIdMessageSendTopologyConvention<T>>( () => { var convention = new CorrelationIdMessageSendTopologyConvention<T>(); convention.SetCorrelationId(new NullableDelegateMessageCorrelationId<T>(correlationIdSelector)); return convention; }, update => { update.SetCorrelationId(new NullableDelegateMessageCorrelationId<T>(correlationIdSelector)); return update; }); } /// <summary> /// Specify for the message type that the delegate be used for setting the CorrelationId /// property of the message envelope. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="configurator"></param> /// <param name="correlationIdSelector"></param> public static void UseCorrelationId<T>(this ISendTopology configurator, Func<T, Guid> correlationIdSelector) where T : class { configurator.GetMessageTopology<T>().UseCorrelationId(correlationIdSelector); } /// <summary> /// Specify for the message type that the delegate be used for setting the CorrelationId /// property of the message envelope. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="configurator"></param> /// <param name="correlationIdSelector"></param> public static void UseCorrelationId<T>(this ISendTopology configurator, Func<T, Guid?> correlationIdSelector) where T : class { configurator.GetMessageTopology<T>().UseCorrelationId(correlationIdSelector); } } }