[英]Azure Durable entity functions to get & set timestamp info using timer trigger
I am trying to store the time stamp information in durable entities and retrieve it every time a trigger fired.我正在尝试将时间戳信息存储在持久实体中,并在每次触发触发器时检索它。 Here is how I am doing it.这是我的做法。 I want the timestamp value set by the current execution to be available for the next trigger.我希望当前执行设置的时间戳值可用于下一个触发器。 But when the control reaches "string prevTS = await context.CallEntityAsync(entityId, "Get");"但是当控件到达“string prevTS = await context.CallEntityAsync(entityId, "Get");”时to goes back to start of the function again.再次回到 function 的开始。 What am I missing here.我在这里想念什么。
I want execution to be sequential between the timer triggers.我希望在计时器触发器之间按顺序执行。 ''' '''
***public static class GetOpenDataRealtimeFeed
{
[FunctionName("GetOpenDataOrchestrator")]
public static async Task<List<string>> RunOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context, Binder binder, ILogger log)
{
var outputs = new List<string>();
var entityId = new EntityId(nameof(GetPrevLastModifiedTimestamp), "entityKey2");
string prevTS = await context.CallEntityAsync<string>(entityId, "Get");
string currentTS = DateTime.Now.ToString();
outputs.Add(currentTS);
outputs.Add(prevTS);
context.SignalEntity(entityId, "Set", currentTS);
return null;
}
//Durable entity function to get & set the last modified timestamp
[FunctionName("GetPrevLastModifiedTimestamp")]
public static void GetPrevLastModifiedTimestamp([EntityTrigger] IDurableEntityContext ctx)
{
switch (ctx.OperationName.ToLowerInvariant())
{
case "set":
ctx.SetState(ctx.GetInput<string>());
break;
case "get":
ctx.Return(ctx.GetState<string>());
break;
}
}
[FunctionName("getOpenDataRealtimeFeed_Trigger")]
public static async Task Run(
[TimerTrigger("%triggerTimer%")] TimerInfo myTimer,
[DurableClient] IDurableOrchestrationClient starter,
ILogger log)
{
// Function input comes from the request content.
string instanceId = await starter.StartNewAsync("GetOpenDataOrchestrator", null);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
}
}
}***
''' '''
I assume you are referring to the current line while debugging.我假设您在调试时指的是当前行。 If so, this is expected .如果是这样,这是意料之中的。
Since Durable Functions replays functions after await
ing a durable client call, execution won't ever go through the first round.由于 Durable Functions 在await
一个持久客户端调用后重放函数,因此在第一轮中永远不会执行 go。 Only the final replay will be "sequential" step overs.只有最后的重播将是“连续的”跨步。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.