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

原文地址:http://www.cnblogs.com/loogn/p/9007793.html

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

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

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

    "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查询字符串。

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

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

posted @ 2018-06-07 17:09  snailteam  阅读(380)  评论(0编辑  收藏  举报