private static object GetMessage(ConsumeContext consumeContext) { var consumeContextMessagePropertyOfT = ConsumeContextMessagePropertiesOfT.GetOrAdd( consumeContext.GetType(), x => { var messageType = consumeContext .GetType() .GetGenericArguments() .Single(); var genericConsumeContextType = typeof(ConsumeContext <>).MakeGenericType(messageType); var messageProperty = genericConsumeContextType.GetProperty("Message", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty); return(messageProperty); }); return(consumeContextMessagePropertyOfT.GetValue(consumeContext)); }
public Maybe <PropertyInfo> GetConsumerProperty <TMessage>(ConsumeContext <TMessage> consumeContext) where TMessage : class { var type = consumeContext.GetType(); if (!_memoryCache.TryGetValue(PropertyInfoKey(type), out PropertyInfo cachedPropertyInfo)) { var propertyInfo = type.GetProperty(nameof(ConsumerConsumeContextScope <object, object> .Consumer)); _memoryCache.Set(PropertyInfoKey(type), propertyInfo); return(propertyInfo); } return(cachedPropertyInfo); }
public static void LogRetry(this ConsumeContext context, Exception exception) { _logRetry(context.ReceiveContext.InputAddress, context.MessageId, TypeMetadataCache.GetShortName(context.GetType()), exception); }