簡體   English   中英

Service Fabric錯誤:“服務不存在”

[英]Service Fabric error: “Service does not exist”

我收到錯誤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 ,則會出現“Service not found”錯誤。

但是,如果我先調用其他方法來執行某些更改(POST),那么它的工作原理......很奇怪吧? 這是我的回購,以幫助看看代碼。

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

在此輸入圖像描述

在@ maf748的幫助下,我為所有CLR異常打開了“Break When Thrown”配置,我發現實際的異常不是“服務不存在”。

在此輸入圖像描述

在我的例子中,我為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);
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM