侧边栏

Ocelot中文文档-微服务ServiceFabric(转)

原文地址:https://www.cnblogs.com/snaildev/articles/9151694.html

如果您在Service Fabric中部署了服务,则通常会使用命名服务来访问它们。

以下示例展示如何设置一个ReRoute以便在在Service Fabric中工作。 最重要的是ServiceName,它由Service Fabric应用程序名称和特定服务名称组成的。 我们还需要将UseServiceDiscovery设置为true,并在GlobalConfiguration中设置ServiceDiscoveryProvider。 这里的例子显示了一个典型的配置。 它假定Service Fabric在本地主机上运行,并且命名服务位于19081端口上。

下面的例子来例子本文件夹,所以请检查它配置是否与你的实际情况相符!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    "ReRoutes": [
        {
        "DownstreamPathTemplate""/api/values",
        "UpstreamPathTemplate""/EquipmentInterfaces",
        "UpstreamHttpMethod": [
            "Get"
        ],
        "DownstreamScheme""http",
        "ServiceName""OcelotServiceApplication/OcelotApplicationService",
        "UseServiceDiscovery" :  true
        }
    ],
    "GlobalConfiguration": {
        "RequestIdKey""OcRequestId",
        "ServiceDiscoveryProvider": {
            "Host""localhost",
            "Port": 19081,
            "Type""ServiceFabric"
        }
    }
}

如果您使用无状态/ guest exe服务,ocelot将能够通过命名服务进行代理,而无需其他任何操作。 但是,如果您使用的是有状态/actor服务,则客户端请求必须发送PartitionKind和PartitionKey查询字符串。

1
GET http://ocelot.com/EquipmentInterfaces?PartitionKind=xxx&PartitionKey=xxx

Ocelot无法为您解决这个问题。

如需转载,请在显眼处标明本文链接,谢谢。
posted @ 2022-09-30 15:20  我有我的骄傲  阅读(25)  评论(0)    收藏  举报