Orleans 为Liveness指定SqlServer

Orleans Specify SqlServer for Liveness

我正在尝试为使用 SQL 服务器的 Orleans 设置一个测试环境。这是我的服务器配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<OrleansConfiguration xmlns="urn:orleans">
  <Globals>
    <Liveness LivenessType="SqlServer" DeploymentId="42783519-d64e-44c9-9c29-111111111133" DataConnectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Orleans;Integrated Security=True;" />
    <!--<SeedNode Address="localhost" Port="11111" />-->
  </Globals>
  <Defaults>
    <Networking Address="localhost" Port="11111" />
    <ProxyingGateway Address="localhost" Port="30000" />
    <Tracing DefaultTraceLevel="Info" TraceToConsole="true" TraceToFile="{0}-{1}.log">
      <TraceLevelOverride LogPrefix="Application" TraceLevel="Info" />
    </Tracing>
    <Statistics MetricsTableWriteInterval="30s" PerfCounterWriteInterval="30s" LogWriteInterval="300s" WriteLogStatisticsToTable="true" />
  </Defaults>
  <Override Node="Primary">
    <Networking Address="localhost" Port="11111" />
    <ProxyingGateway Address="localhost" Port="30000" />
  </Override>
</OrleansConfiguration>

当我使用此配置时 运行:

MembershipTableGrain cannot run without Seed node - please check your silo configuration file and make sure it specifies a SeedNode element. Alternatively, you may want to use AzureTable for LivenessType. Parameter name: grain = MembershipTableGrain Exception = System.ArgumentException: MembershipTableGrain cannot run without Seed node - please check your silo configuration file and make sure it specifies a SeedNode element. Alternatively, you may want to use AzureTable for LivenessType.

更进一步,日志显示 Liveness 是 MembershipTableGrain(这是默认值,需要 SeeNode)。我在这里错过了什么?

我发现了问题。这不是更改 Liveness 类型的方法。应该是这样的:

<SystemStore SystemStoreType="SqlServer" DeploymentId="42783519-d64e-44c9-9c29-111111111133" DataConnectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Orleans;Integrated Security=True;" />
<Liveness LivenessType="SqlServer" />

此外,您必须确保参考 "Microsoft.Orleans.OrleansSqlUtils" NuGet 包和 运行 这个 SQL Create Script

我的 SQLServer 成员资格的筒仓配置如下所示

<?xml version="1.0" encoding="utf-8"?>
<OrleansConfiguration xmlns="urn:orleans">
    <Globals>
        <SystemStore SystemStoreType="SqlServer" DeploymentId="YYYYY" DataConnectionString="Server=THESERVER;Database=Orleans;User ID=USER;password=PASSWORD;"/>
    </Globals>
    <Defaults>
        <Networking Address="" Port="11111"/>
        <ProxyingGateway Address="" Port="30000"/>
    </Defaults>
</OrleansConfiguration>

无需指定活体类型。它通过查看 SystemStoreType 来计算。

客户端配置确实需要指定网关

<ClientConfiguration xmlns="urn:orleans">

  <SystemStore SystemStoreType ="SqlServer" 
                 DeploymentId="YYY" 
                 DataConnectionString="Server=THESERVER;Database=Orleans;User ID=USER;password=PASSWORD;" />

  <GatewayProvider ProviderType="SqlServer"/>
</ClientConfiguration>

您也可以使用可编程 API 代替 XML 进行配置。