add event loadbalancing
This commit is contained in:
@@ -13,6 +13,12 @@ public class SimApiSynapseOptions
|
|||||||
public string? AppId { get; set; }
|
public string? AppId { get; set; }
|
||||||
public int RpcTimeout { get; set; } = 3;
|
public int RpcTimeout { get; set; } = 3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event是否使用负载均衡
|
||||||
|
/// 也就是订阅$queue主题,消息会分发给不同的AppId
|
||||||
|
/// 如果false,多个AppId都可以同时收到消息
|
||||||
|
/// </summary>
|
||||||
|
public bool EventLoadBalancing { get; set; } = false;
|
||||||
public bool EnableConfigStore { get; set; } = true;
|
public bool EnableConfigStore { get; set; } = true;
|
||||||
public bool DisableEventClient { get; set; } = false;
|
public bool DisableEventClient { get; set; } = false;
|
||||||
public bool DisableRpcClient { get; set; } = false;
|
public bool DisableRpcClient { get; set; } = false;
|
||||||
|
|||||||
@@ -53,7 +53,12 @@ public partial class Synapse
|
|||||||
};
|
};
|
||||||
foreach (var ev in EventRegistry)
|
foreach (var ev in EventRegistry)
|
||||||
{
|
{
|
||||||
var topic = $"$queue/{esTopicPrefix}{ev.Key}";
|
|
||||||
|
var topic = $"{esTopicPrefix}{ev.Key}";
|
||||||
|
if (Options.EventLoadBalancing)
|
||||||
|
{
|
||||||
|
topic = "$queue/" + topic;
|
||||||
|
}
|
||||||
var evSubOpts = MqttFactory.CreateSubscribeOptionsBuilder()
|
var evSubOpts = MqttFactory.CreateSubscribeOptionsBuilder()
|
||||||
.WithTopicFilter(o => o.WithTopic(topic)).Build();
|
.WithTopicFilter(o => o.WithTopic(topic)).Build();
|
||||||
Client.SubscribeAsync(evSubOpts).Wait();
|
Client.SubscribeAsync(evSubOpts).Wait();
|
||||||
|
|||||||
Reference in New Issue
Block a user