c#-Service Fabric-为状态服务调用命名分区
作者:互联网
我似乎无法弄清楚如何使用ServiceProxy将呼叫发送到特定的命名分区,并且似乎也没有针对此的任何文档.这就是您要对Int64RangePartitionInformation执行的操作
var partitionInformation = (Int64RangePartitionInformation)selectedPartition.PartitionInformation;
var partitionKey = ServicePartitionKey(partitionInformation.LowKey);
IListen listenerClient = ServiceProxy.Create<IListen>(uri,partitionKey );
但是似乎没有办法为NamedPartitionInformation获取ServicePartitionKey.您是否在Uri中包含分区名称?
解决方法:
ServicePartitionKey具有带字符串的重载.
var partitionKey = new ServicePartitionKey("partitionName");
IListen listenerClient = ServiceProxy.Create<IListen>(uri,partitionKey);
您不需要做更多的事情.
但是,如果您不预先知道分区,则需要查询它们:
using(var client = new FabricClient())
{
var partitions = await client.QueryManager.GetPartitionListAsync(serviceName);
foreach (var partition in partitions)
{
var partitionInformation = (NamedPartitionInformation)partition.PartitionInformation;
var partitionKey = ServicePartitionKey(partitionInformation.Name);
IListen listenerClient = ServiceProxy.Create<IListen>(uri,partitionKey);
}
}
标签:azure-service-fabric,c 来源: https://codeday.me/bug/20191111/2017920.html