/// <summary>
        /// Set the host headers on the SendContext (for error, dead-letter, etc.)
        /// </summary>
        /// <param name="adapter"></param>
        /// <param name="headers"></param>
        /// <param name="exceptionContext"></param>
        public static void SetExceptionHeaders <T>(this ITransportSetHeaderAdapter <T> adapter, IDictionary <string, T> headers, ExceptionReceiveContext
                                                   exceptionContext)
        {
            var exception = exceptionContext.Exception.GetBaseException() ?? exceptionContext.Exception;

            var exceptionMessage = ExceptionUtil.GetMessage(exception);

            adapter.Set(headers, MessageHeaders.Reason, "fault");

            adapter.Set(headers, MessageHeaders.FaultExceptionType, TypeMetadataCache.GetShortName(exception.GetType()));
            adapter.Set(headers, MessageHeaders.FaultMessage, exceptionMessage);
            adapter.Set(headers, MessageHeaders.FaultTimestamp, exceptionContext.ExceptionTimestamp);
            adapter.Set(headers, MessageHeaders.FaultStackTrace, ExceptionUtil.GetStackTrace(exception));

            if (exceptionContext.TryGetPayload(out ConsumerFaultInfo info))
            {
                adapter.Set(headers, MessageHeaders.FaultConsumerType, info.ConsumerType);
                adapter.Set(headers, MessageHeaders.FaultMessageType, info.MessageType);
            }

            if (exceptionContext.TryGetPayload(out RetryContext retryContext) && retryContext.RetryCount > 0)
            {
                adapter.Set(headers, MessageHeaders.FaultRetryCount, retryContext.RetryCount);
            }
        }
 public static void Set <TValueType>(this ITransportSetHeaderAdapter <TValueType> adapter, IDictionary <string, TValueType> dictionary,
                                     IEnumerable <HeaderValue> headerValues)
 {
     foreach (HeaderValue header in headerValues)
     {
         adapter.Set(dictionary, header);
     }
 }
 public static void Set <TValueType>(this ITransportSetHeaderAdapter <TValueType> adapter, IDictionary <string, TValueType> dictionary, string key,
                                     DateTime?value, Func <DateTime, string> formatter)
 {
     if (value.HasValue)
     {
         adapter.Set(dictionary, new HeaderValue <string>(key, formatter(value.Value)));
     }
 }
 public static void Set <TValueType>(this ITransportSetHeaderAdapter <TValueType> adapter, IDictionary <string, TValueType> dictionary, string key,
                                     TimeSpan?value)
 {
     if (value.HasValue)
     {
         adapter.Set(dictionary, new HeaderValue <string>(key, ToString(value.Value)));
     }
 }
 public static void Set <TValueType>(this ITransportSetHeaderAdapter <TValueType> adapter, IDictionary <string, TValueType> dictionary, string key,
                                     string value)
 {
     if (!string.IsNullOrWhiteSpace(value))
     {
         adapter.Set(dictionary, new HeaderValue <string>(key, value));
     }
 }
 /// <summary>
 /// Set the host headers on the SendContext (for error, dead-letter, etc.)
 /// </summary>
 /// <param name="adapter"></param>
 /// <param name="dictionary"></param>
 public static void SetHostHeaders <T>(this ITransportSetHeaderAdapter <T> adapter, IDictionary <string, T> dictionary)
 {
     adapter.Set(dictionary, MessageHeaders.Host.MachineName, HostMetadataCache.Host.MachineName);
     adapter.Set(dictionary, MessageHeaders.Host.ProcessName, HostMetadataCache.Host.ProcessName);
     adapter.Set(dictionary, MessageHeaders.Host.ProcessId, HostMetadataCache.Host.ProcessId);
     adapter.Set(dictionary, MessageHeaders.Host.Assembly, HostMetadataCache.Host.Assembly);
     adapter.Set(dictionary, MessageHeaders.Host.AssemblyVersion, HostMetadataCache.Host.AssemblyVersion);
     adapter.Set(dictionary, MessageHeaders.Host.MassTransitVersion, HostMetadataCache.Host.MassTransitVersion);
     adapter.Set(dictionary, MessageHeaders.Host.FrameworkVersion, HostMetadataCache.Host.FrameworkVersion);
     adapter.Set(dictionary, MessageHeaders.Host.OperatingSystemVersion, HostMetadataCache.Host.OperatingSystemVersion);
 }
예제 #7
0
 public SqsErrorTransport(string destination, ITransportSetHeaderAdapter <MessageAttributeValue> headerAdapter, IFilter <ClientContext> topologyFilter)
     : base(destination, topologyFilter)
 {
     _headerAdapter = headerAdapter;
 }
 public DictionaryHeadersSerializer(ITransportSetHeaderAdapter <Header> adapter)
 {
     _adapter = adapter;
 }