diff --git a/src/DotNetCore.CAP/Abstractions/TopicAttribute.cs b/src/DotNetCore.CAP/Abstractions/TopicAttribute.cs
index 454572f..59dd897 100644
--- a/src/DotNetCore.CAP/Abstractions/TopicAttribute.cs
+++ b/src/DotNetCore.CAP/Abstractions/TopicAttribute.cs
@@ -20,9 +20,10 @@ namespace DotNetCore.CAP.Abstractions
public string Name { get; }
///
+ /// Default group name is CapOptions setting.(Assembly name)
/// kafka --> groups.id
/// rabbit MQ --> queue.name
///
- public string Group { get; set; } = "cap.default.group";
+ public string Group { get; set; }
}
}
\ No newline at end of file
diff --git a/src/DotNetCore.CAP/CAP.Options.cs b/src/DotNetCore.CAP/CAP.Options.cs
index b80d0e0..a7f6198 100644
--- a/src/DotNetCore.CAP/CAP.Options.cs
+++ b/src/DotNetCore.CAP/CAP.Options.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Reflection;
using DotNetCore.CAP.Models;
namespace DotNetCore.CAP
@@ -34,6 +35,7 @@ namespace DotNetCore.CAP
///
public const int DefaultFailedRetryCount = 100;
+
public CapOptions()
{
PollingDelay = DefaultPollingDelay;
@@ -42,10 +44,16 @@ namespace DotNetCore.CAP
FailedRetryInterval = DefaultFailedMessageWaitingInterval;
FailedRetryCount = DefaultFailedRetryCount;
Extensions = new List();
+ DefaultGroup = "cap.queue." + Assembly.GetEntryAssembly().GetName().Name.ToLower();
}
internal IList Extensions { get; }
+ ///
+ /// Subscriber default group name. kafka-->group name. rabbitmq --> queue name.
+ ///
+ public string DefaultGroup { get; set; }
+
///
/// Producer job polling delay time.
/// Default is 15 sec.
diff --git a/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs b/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs
index 1d23740..e20d306 100644
--- a/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs
+++ b/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs
@@ -10,23 +10,26 @@ namespace DotNetCore.CAP.Internal
{
///
///
- /// A default implementation.
+ /// A default implementation.
///
internal class DefaultConsumerServiceSelector : IConsumerServiceSelector
{
+ private readonly CapOptions _capOptions;
private readonly IServiceProvider _serviceProvider;
///
- /// Creates a new .
+ /// Creates a new .
///
- public DefaultConsumerServiceSelector(IServiceProvider serviceProvider)
+ public DefaultConsumerServiceSelector(IServiceProvider serviceProvider, CapOptions capOptions)
{
_serviceProvider = serviceProvider;
+ _capOptions = capOptions;
}
///
- /// Selects the best candidate from for the
- /// current message associated.
+ /// Selects the best candidate from for
+ /// the
+ /// current message associated.
///
public ConsumerExecutorDescriptor SelectBestCandidate(string key,
IReadOnlyList executeDescriptor)
@@ -45,7 +48,7 @@ namespace DotNetCore.CAP.Internal
return executorDescriptorList;
}
- private static IEnumerable FindConsumersFromInterfaceTypes(
+ private IEnumerable FindConsumersFromInterfaceTypes(
IServiceProvider provider)
{
var executorDescriptorList = new List();
@@ -66,7 +69,7 @@ namespace DotNetCore.CAP.Internal
}
}
- private static IEnumerable FindConsumersFromControllerTypes()
+ private IEnumerable FindConsumersFromControllerTypes()
{
var executorDescriptorList = new List();
@@ -81,18 +84,21 @@ namespace DotNetCore.CAP.Internal
return executorDescriptorList;
}
- private static IEnumerable GetTopicAttributesDescription(TypeInfo typeInfo)
+ private IEnumerable GetTopicAttributesDescription(TypeInfo typeInfo)
{
foreach (var method in typeInfo.DeclaredMethods)
{
var topicAttr = method.GetCustomAttributes(true);
-
var topicAttributes = topicAttr as IList ?? topicAttr.ToList();
if (!topicAttributes.Any()) continue;
foreach (var attr in topicAttributes)
+ {
+ if (attr.Group == null)
+ attr.Group = _capOptions.DefaultGroup;
yield return InitDescriptor(attr, method, typeInfo);
+ }
}
}