我正在尝试在本地逐步执行(使用 Visual Studio 2019)Durable 功能,但是当我从 OrchestrationTrigger 调用 context.CallActivityWithRetryAsync("MyActivity_Activity", retryOptions, myActivityParameters) 时,该调用始终返回以下内容:
Id = [xxxx],状态 = WaitingForActivation,方法 =“{null}”,结果 =“{尚未计算}”
我的第一个猜测是某处可能存在死锁,但我重新启动了我的机器,仍然看到相同的结果。另外,我尝试在活动的第一行(MyActivity_Activity)设置断点,但没有命中。任何帮助将不胜感激!
使用以下内容:
- VS 2019 专业版
- .Net 核心 2.2
- Microsoft.Azure.DurableTask.AzureStorage v1.6.2
- Microsoft.Azure.WebJobs.Extensions.DurableTask v1.8.2
Microsoft.NET.Sdk.Functions v1.0.29
...等。
以下是一些相关的代码片段:
[FunctionName("MyOrchestrator_HttpStart")]
public static async Task<HttpResponseMessage> HttpStart(
[HttpTrigger(AuthorizationLevel.Function, "post")]HttpRequestMessage req,
[OrchestrationClient]DurableOrchestrationClient starter, ExecutionContext executionContext)
{
string instanceId = string.Empty;
MyOrchestratorParameters myOrchestratorParameters = await req.Content.ReadAsAsync<MyOrchestratorParameters>();
instanceId = await starter.StartNewAsync("MyOrchestrator", myOrchestratorParameters);
return starter.CreateCheckStatusResponse(req, instanceId);
}
[FunctionName("MyOrchestrator")]
public static async Task RunOrchestrator(
[OrchestrationTrigger] DurableOrchestrationContext context,
ExecutionContext executionContext)
{
MyOrchestratorParameters myOrchestratorParameters =
context.GetInput<MyOrchestratorParameters>();
ValidateParameters(myOrchestratorParameters);
var delay = 3000;
var retry = 3;
var retryOptions = new
RetryOptions(TimeSpan.FromSeconds(delay), retry);
MyActivityParameters myActivityParameters = new
MyActivityParameters()
{
JobNumber = myOrchestratorParameters.JobNumber,
Stage = myOrchestratorParameters.Stage,
TemplateId = myOrchestratorParameters.TemplateId
};
myActivityResults =
context.CallActivityWithRetryAsync<MyActivityResult>
("MyActivity_Activity", retryOptions, myActivityParameters);
...
}
[FunctionName("MyActivity_Activity")]
public static async Task<MyActivityResult>
RunActivity([ActivityTrigger] DurableActivityContext
activityContext, ExecutionContext executionContext)
{
var _myActivityParameters =
activityContext.GetInput<MyActivityParameters>();
//do some stuff & return MyActivityResult object
}