【问题标题】:Service Fabric error: "Service does not exist"Service Fabric 错误:“服务不存在”
【发布时间】:2019-10-28 02:52:19
【问题描述】:

我收到错误FabricServiceNotFoundException: Service does not exist.,我不知道为什么。我正在创建的服务名称正是它在我的集群中部署的名称。

这是我创建服务的代码:

return ServiceProxy.Create<ICheckoutService>(
                new Uri("fabric:/ECommerce/ECommerce.CheckoutService"),
                new ServicePartitionKey(0));

这是资源管理器视图。服务名称与我的代码匹配。我正在使用其他服务没有问题。

我尝试了完全重启,但我得到了同样的错误:

  1. 从集群中删除应用程序
  2. 集群中未配置的类型
  3. 重启集群
  4. 重新启动 Visual Studio
  5. 重建和部署应用程序

更新

经过测试,我发现错误的发生取决于我通过 API 方法调用服务的顺序。

如果我部署应用程序并调用 checkoutget basket 方法,它们会给出“找不到服务”错误。

但是,如果我首先调用其他方法来执行一些更改(POST),那么它会起作用……很奇怪吧?这是我的仓库,可以帮助查看代码。

https://github.com/epomatti/azure-servicefabric-productcatalog

【问题讨论】:

  • 您最近是否执行过任何缩放操作,之后您会看到此问题?
  • @KarishmaTiwari-MSFT 我没有。刚刚创建了新服务。
  • 我之前遇到过这种情况,SF 通常不会有最好的错误消息:对我来说,由于客户端之间的不匹配,在创建代理时找不到接口类型和服务。确保包含接口的程序集在所有项目中都是共享的并且是最新的。
  • 通常帮助我获得更好的错误消息的另一种方法是将 Visual Studio 异常设置切换为“抛出时中断”。快速失败允许访问异常和更接近实际问题的调用堆栈。
  • @maf748 更新了问题,看看是否告诉您有关问题的任何线索。我尝试了你的建议,但还没有。

标签: c# azure-service-fabric


【解决方案1】:

在@maf748 的帮助下,我为所有 CLR 异常打开了“抛出时中断”配置,我发现实际的异常不是“服务不存在”。

就我而言,我为 Actor 服务留下了以下自动生成的方法,该方法将我的状态设置为错误状态,后来在我自己的代码中失败了。

我需要做的就是删除 Visual Studio 从我的方法中创建的这个方法,它可以正常工作。

    /// <summary>
    /// This method is called whenever an actor is activated.
    /// An actor is activated the first time any of its methods are invoked.
    /// </summary>
    protected override Task OnActivateAsync()
    {
        ActorEventSource.Current.ActorMessage(this, "Actor activated.");

        // The StateManager is this actor's private state store.
        // Data stored in the StateManager will be replicated for high-availability for actors that use volatile or persisted state storage.
        // Any serializable object can be saved in the StateManager.
        // For more information, see https://aka.ms/servicefabricactorsstateserialization

        return this.StateManager.TryAddStateAsync("count", 0);
    }

【讨论】:

    猜你喜欢
    • 2018-07-21
    • 1970-01-01
    • 2018-10-30
    • 2018-01-16
    • 2020-01-23
    • 2017-10-30
    • 2018-08-08
    • 2017-03-14
    • 2016-12-07
    相关资源
    最近更新 更多