IReadOnlyDictionary <Type, MessageSubscriberAttribute> GetAttributeMapping(Type messageType, string defaultGroupName, int defaultTopicQueueCount) { var attributes = new Dictionary <Type, MessageSubscriberAttribute>(); foreach (var type in typeFinder.GetTypesBySpecifiedType(messageType, assemblies)) { var attribute = type.GetTypeInfo().GetCustomAttribute <MessageSubscriberAttribute>(true); if (attribute != null) { if (string.IsNullOrWhiteSpace(attribute.Topic)) { throw new Exception($"订阅者主题不能为空。 [SubscriberType = {type}]"); } if (string.IsNullOrWhiteSpace(attribute.GroupName) && !string.IsNullOrWhiteSpace(defaultGroupName)) { attribute.GroupName = defaultGroupName; } if (attribute.TopicQueueCount <= 0) { if (defaultTopicQueueCount <= 0) { throw new Exception($"默认主题队列数量小于 1 。"); } attribute.TopicQueueCount = defaultTopicQueueCount; } attributes.Add(type, attribute); } } return(attributes); }