You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by aa...@apache.org on 2022/12/07 11:15:43 UTC
[rocketmq-clients] branch master updated: Bugfix: producer does not override BuildClientSetting
This is an automated email from the ASF dual-hosted git repository.
aaronai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/master by this push:
new 71d58d90 Bugfix: producer does not override BuildClientSetting
71d58d90 is described below
commit 71d58d9062a6ce314ef9ddf1758d11cdb563c00f
Author: Aaron Ai <ya...@gmail.com>
AuthorDate: Wed Dec 7 14:01:43 2022 +0800
Bugfix: producer does not override BuildClientSetting
---
csharp/rocketmq-client-csharp/Client.cs | 2 +-
csharp/rocketmq-client-csharp/Producer.cs | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/csharp/rocketmq-client-csharp/Client.cs b/csharp/rocketmq-client-csharp/Client.cs
index 2e6a6ec6..ea44abf9 100644
--- a/csharp/rocketmq-client-csharp/Client.cs
+++ b/csharp/rocketmq-client-csharp/Client.cs
@@ -509,7 +509,7 @@ namespace Org.Apache.Rocketmq
protected readonly IClientManager Manager;
- private readonly HashSet<string> _topicsOfInterest = new HashSet<string>();
+ protected readonly HashSet<string> _topicsOfInterest = new HashSet<string>();
public void AddTopicOfInterest(string topic)
{
diff --git a/csharp/rocketmq-client-csharp/Producer.cs b/csharp/rocketmq-client-csharp/Producer.cs
index 7d559043..c2c5e5db 100644
--- a/csharp/rocketmq-client-csharp/Producer.cs
+++ b/csharp/rocketmq-client-csharp/Producer.cs
@@ -83,8 +83,30 @@ namespace Org.Apache.Rocketmq
// Concept of ProducerGroup has been removed.
}
+ public override void BuildClientSetting(rmq::Settings settings)
+ {
+ base.BuildClientSetting(settings);
+
+ settings.ClientType = rmq.ClientType.Producer;
+ var publishing = new rmq.Publishing();
+
+ foreach (var topic in _topicsOfInterest)
+ {
+ var resource = new rmq.Resource()
+ {
+ Name = topic,
+ ResourceNamespace = ResourceNamespace
+ };
+ publishing.Topics.Add(resource);
+ }
+
+ settings.Publishing = publishing;
+ }
+
public async Task<SendReceipt> Send(Message message)
{
+ _topicsOfInterest.Add(message.Topic);
+
if (!_loadBalancer.ContainsKey(message.Topic))
{
var topicRouteData = await GetRouteFor(message.Topic, false);