微服务之间的Service Fabric wcf通信

安杰拉·科斯蒂奇(Andjela Krstic)

我正在尝试在两个微服务之间进行简单的通信。到目前为止,作为接收者

protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
    {

        return new[]
        {
            new ServiceInstanceListener((context) =>
                new WcfCommunicationListener<ITest>(
                    wcfServiceObject: new Test(),
                    serviceContext: context,
                    endpointResourceName: "ProgramTestEndpoint",
                    listenerBinding: WcfUtility.CreateTcpListenerBinding()
                ),
                name: "ProgramTestListener"
            )
        };
    }

    public class Test : ITest
{
    public async Task<int> ReturnsInt()
    {
        return 2;
    }
}

 [ServiceContract]
public interface ITest
{
    [OperationContract]
    Task<int> ReturnsInt();


}

我确实向服务清单添加了端点。

<Endpoint Name ="ProgramTestEndpoint"/>

要通信的微服务具有此代码

 protected override async Task RunAsync(CancellationToken cancellationToken)
    {
        // TODO: Replace the following sample code with your own logic 
        //       or remove this RunAsync override if it's not needed in your service.

        await Task.Delay(5000);

        CloudClient<ITest> transactionCoordinator = new CloudClient<ITest>
       (
           serviceUri: new Uri($"{Context.CodePackageActivationContext.ApplicationName}/MyStateless"),
           partitionKey: new ServicePartitionKey(0),
           clientBinding: WcfUtility.CreateTcpClientBinding(),
           listenerName: "MyStateless"
       );


        int iterations = await transactionCoordinator.InvokeWithRetryAsync(client => client.Channel.ReturnsInt());
        ServiceEventSource.Current.ServiceMessage(this.Context, "Test-{0}", ++iterations);
        while (true)
        {
            cancellationToken.ThrowIfCancellationRequested();

            ServiceEventSource.Current.ServiceMessage(this.Context, "Working-{0}", ++iterations);

            await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
        }
    }

这是我在服务结构中的第一个项目,我不确定自己做错了什么,但是使用此代码,应用程序无法接收ReturnInt任务的返回值。

奥立佛

创建与无状态服务的连接时,应使用ServicePartitionKey.Singleton分区键。在某些情况下,您根本不需要指定一个,例如,用于ServiceProxyFactory创建到无状态服务的连接时。

使用new ServicePartitionKey(0)导致客户端尝试连接到不存在的端点。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

WCF通信的Service Fabric可靠服务

来自分类Dev

在 Service Fabric 中与容器化 WCF 服务通信

来自分类Dev

微服务之间的通信

来自分类Dev

在 Azure Service Fabric 中托管 WCF 服务

来自分类Dev

Azure Service Fabric actor微服务

来自分类Dev

Service Fabric服务中的多个通信侦听器

来自分类Dev

Service Fabric服务中的多个通信侦听器

来自分类Dev

通过Service Fabric中的http公开公开WCF Restful服务

来自分类Dev

Azure Service Fabric中WCF服务的HTTP端点

来自分类Dev

NestJS-2个微服务之间的通信

来自分类Dev

Azure 逻辑应用程序 - 微服务之间的 HTTP 通信

来自分类Dev

模式拼接的 graphql 微服务约定之间的通信

来自分类Dev

如何通过WCF与Windows Service通信?

来自分类Dev

微服务通信

来自分类Dev

微服务通信/部署

来自分类Dev

微服务通信安全

来自分类Dev

同步通信微服务

来自分类Dev

使用Azure Service Fabric部署的微服务的API网关/代理模式

来自分类Dev

权衡和使用Azure Service Fabric构建微服务的最佳实践

来自分类Dev

Nancy/OWIN Service Fabric 微服务向临时文件写入请求

来自分类Dev

通过Web代理与WCF服务进行通信;从Windows服务中

来自分类Dev

通过Web代理与WCF服务进行通信;从Windows服务中

来自分类Dev

由于服务的“FaultedState”,WCF.ServiceChannel 无法通信

来自分类Dev

分别部署Service Fabric服务

来自分类Dev

如何使用WCF在应用程序和Windows服务之间进行通信?

来自分类Dev

服务间WCF REST调用是在应用程序组件之间进行通信的最佳方式吗?

来自分类Dev

asp.net网站与Azure中的Kubernetes / docker微服务之间的通信

来自分类Dev

使用由Lambda函数支持的API网关,该函数使用SNS在微服务之间进行通信

来自分类Dev

Spring Boot微服务应用之间如何通信用户ID

Related 相关文章

  1. 1

    WCF通信的Service Fabric可靠服务

  2. 2

    在 Service Fabric 中与容器化 WCF 服务通信

  3. 3

    微服务之间的通信

  4. 4

    在 Azure Service Fabric 中托管 WCF 服务

  5. 5

    Azure Service Fabric actor微服务

  6. 6

    Service Fabric服务中的多个通信侦听器

  7. 7

    Service Fabric服务中的多个通信侦听器

  8. 8

    通过Service Fabric中的http公开公开WCF Restful服务

  9. 9

    Azure Service Fabric中WCF服务的HTTP端点

  10. 10

    NestJS-2个微服务之间的通信

  11. 11

    Azure 逻辑应用程序 - 微服务之间的 HTTP 通信

  12. 12

    模式拼接的 graphql 微服务约定之间的通信

  13. 13

    如何通过WCF与Windows Service通信?

  14. 14

    微服务通信

  15. 15

    微服务通信/部署

  16. 16

    微服务通信安全

  17. 17

    同步通信微服务

  18. 18

    使用Azure Service Fabric部署的微服务的API网关/代理模式

  19. 19

    权衡和使用Azure Service Fabric构建微服务的最佳实践

  20. 20

    Nancy/OWIN Service Fabric 微服务向临时文件写入请求

  21. 21

    通过Web代理与WCF服务进行通信;从Windows服务中

  22. 22

    通过Web代理与WCF服务进行通信;从Windows服务中

  23. 23

    由于服务的“FaultedState”,WCF.ServiceChannel 无法通信

  24. 24

    分别部署Service Fabric服务

  25. 25

    如何使用WCF在应用程序和Windows服务之间进行通信?

  26. 26

    服务间WCF REST调用是在应用程序组件之间进行通信的最佳方式吗?

  27. 27

    asp.net网站与Azure中的Kubernetes / docker微服务之间的通信

  28. 28

    使用由Lambda函数支持的API网关,该函数使用SNS在微服务之间进行通信

  29. 29

    Spring Boot微服务应用之间如何通信用户ID

热门标签

归档