-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for group and topic prefixes #780
Conversation
Hello, Thanks for your PR, Since GroupName is customizable, so I think it is redundant to provide GroupNamePrefix I think it is reasonable to provide TopicNamePrefix |
@yang-xiaodong At the moment it is a bit fussy overriding the way how the group name constructs. For simple cases like providing prefixes to host multiple instances within the same infrastructure, it would be more pleasant to have a consistent way to set up prefixes for both queues and topics, even if there is an alternative way. What are your concerns? |
What I think is that providing more configuration items will complicate the beginner and keep it simple. Do as you say at present we have the configuration items |
@@ -34,6 +34,16 @@ public CapOptions() | |||
/// </summary> | |||
public string DefaultGroup { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described in the comments, rename DefaultGroup
to GroupName
seemed more appropriate
Currently, we configure public class PrefixedConsumerServiceSelector : ConsumerServiceSelector
{
private readonly string _prefix;
public PrefixedConsumerServiceSelector(IServiceProvider serviceProvider, string prefix)
: base(serviceProvider)
{
_prefix = prefix;
}
protected override void SetSubscribeAttribute(TopicAttribute attribute)
{
base.SetSubscribeAttribute(attribute);
if (!string.IsNullOrEmpty(_prefix))
{
attribute.Group = $"{_prefix}.{attribute.Group}";
}
}
} And then in services.AddCap(c => ...);
services.TryRemove<IConsumerServiceSelector>();
services.TryAddSingleton<IConsumerServiceSelector>(s => new PrefixedConsumerServiceSelector(s, "MyPerfix")); Possibly, I understand this overring incorrectly, but I think there could be a more simple approach just to add prefix like services.AddCap(c => {
c.GroupNamePrefix = "MyGroupPrefix",
c.TopicNamePrefix = "MyTopicPrefix"
}); Since |
Dear @yang-xiaodong, |
well, I want let you know I will rename options |
Preview version |
Thank you very much, @yang-xiaodong! |
Problem
We have multiple instances of the app, which deployed to AWS in different VPCs but in the same region. In this scenario, isolation works perfectly except for SNS and SQS, which are shared within the region.
Proposed solution
Add to
CapOptions
prefixes for topic (TopicNamePrefix
) and group (GroupNamePrefix
) names to make these parameters unique for each application instance. These parameters are optional, and if not defined the behavior will remain unchanged.