0
A
回答
0
是,您可以在ApplicationManifest.xml
更改服务的名称不是从服务的类名取名字以外的东西。
Short:只是将ApplicationManifest.xml
中的name
属性更改为其他内容。
在代码:如果我有这样的服务:
public interface IJustAnotherStatelessService : IService
{
Task<string> SayHelloAsync(string someValue);
}
internal sealed class JustAnotherStatelessService : StatelessService, IJustAnotherStatelessService
{
// Service implementation
}
注册于Program.cs
这样的:
ServiceRuntime.RegisterServiceAsync("JustAnotherStatelessServiceType",
context => new JustAnotherStatelessService(context)).GetAwaiter().GetResult();
而在ServiceManifest.xml
该服务
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest ...>
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="JustAnotherStatelessServiceType" />
</ServiceTypes>
...
在ApplicationManifest.xml
你会得到建议的名称:
<ApplicationManifest ...>
<DefaultServices>
<Service Name="JustAnotherStatelessService">
<StatelessService ServiceTypeName="JustAnotherStatelessServiceType" InstanceCount="[JustAnotherStatelessService_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
这会给你一个开放的,以您服务像
fabric:/app_name/JustAnotherStatelessService
现在,继续前进,在应用程序清单更改名称:
<ApplicationManifest ...>
<DefaultServices>
<Service Name="AwesomeService">
<StatelessService ServiceTypeName="JustAnotherStatelessServiceType" InstanceCount="[JustAnotherStatelessService_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
和您的服务现在答案来
fabric:/app_name/AwesomeService
0
您可以使用此URI建设者从这里(ServiceUriBuilder.cs)类:https://github.com/Azure-Samples/service-fabric-dotnet-web-reference-app/blob/master/ReferenceApp/Common/ServiceUriBuilder.cs
对于无状态的服务,您可以轻松地获得代理:
var serviceUri = new ServiceUriBuilder(ServiceName);
var proxyFactory = new ServiceProxyFactory();
var svc = proxyFactory.CreateServiceProxy<IServiceName>(serviceUri.ToUri());
对于状态服务,你必须指定分区。
var serviceUri = new ServiceUriBuilder(StatefulServiceName);
var proxyFactory = new ServiceProxyFactory();
//this is just a sample of partition 1 if you are using number partitioning.
var partition = new ServicePartitionKey(1);
var svc = proxyFactory.CreateServiceProxy<IStatefulServiceName>(serviceUri.ToUri(), partition);
相关问题
- 1. Symfony2服务结构
- 2. 服务结构SetupEntryPoint
- 3. 使用服务结构的服务体系结构
- 4. Azure服务结构:无法运行本地服务结构簇
- 5. 的.htaccess特定URL结构
- 6. 笨自定义URL结构
- 7. 服务结构服务与用户表示的服务结构参与者
- 8. 指针结构
- 9. 指针结构
- 10. 结构指针
- 11. 结构指针
- 12. 结构指针
- 13. 结构指针
- 14. 指定json.Marshal结构格式()
- 15. 服务结构 - MissingMethodException ClearAsync()
- 16. Azure服务结构与ApplicationGateway
- 17. 服务结构ServicePartitionResolver ResolveAsync
- 18. 带服务结构的Microsoft.SqlServer.Types
- 19. 服务结构流模式
- 20. Azure结构服务 - 如何
- 21. ASP.NET网络服务架构/结构
- 22. 结构建设构建服务器
- 23. 服务结构 - 架构决策 - 图片
- 24. 结构或指针的结构?
- 25. 带结构字段指针的结构
- 26. Django服务器结构和约定
- 27. 包含结构的结构与包含指针的结构
- 28. 服务结构有状态OData服务
- 29. Azure服务结构服务间通信
- 30. 无法启动服务结构服务
谢谢你的回应,我相信我不清楚我的要求。我想知道你是否可以让应用程序监听'fabric:/ foobarbazservice',但我不认为这是可能的,因为服务解析器在应用程序类型内寻找服务类型,并且不能,比如说随机选择一个! – Mardoxx
不,在那部分你是对的,你被限制在url的{applicationName}/{serviceName_set_in_ApplicationManifest}方案。我没有看到任何方式设置完全自定义的网址给予织物运输方式建立它的Url内部。 – yoape