java 客户端的 Cadence 重试选项示例
Retry Option Example in Cadence for java client
我正在寻找 java 中节奏的重试选项示例,例如我正在尝试下面的代码片段,但似乎 activity 没有重试
@ActivityMethod(scheduleToCloseTimeoutSeconds = 30)
@MethodRetry(maximumAttempts = 2, initialIntervalSeconds = 1, expirationSeconds = 30, maximumIntervalSeconds = 30)
String getGreetingContentOverTheWeb(URL url) throws IOException;
对于上面的 activity 我希望如果它失败应该自动重试,下面是我如何调用它
@Override
public String getGreeting(String name) {
// This is a blocking call that returns only after the activity has completed.
try {
String content = activities.getGreetingContentOverTheWeb(new URL("http://localhost:3000/import-map/books"));
return activities.composeGreeting(content, name);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return activities.composeGreeting("Hello", name);
}
如果我在这里做错了什么,请告诉我,
下面是前端的截图
从事件历史来看,activity 似乎被重试了。我通过查看 ActivityTaskStarted.attempt
字段来确定它。那里的数字等于重试次数。因此 activity 根据指定的重试策略恰好执行了两次请求。
我知道这个名字非常令人困惑,因为尝试应该从 1 而不是从 0 开始。我们已经 fixed this in the temporal.io 我的团队维护的 Cadence 分支。
我正在寻找 java 中节奏的重试选项示例,例如我正在尝试下面的代码片段,但似乎 activity 没有重试
@ActivityMethod(scheduleToCloseTimeoutSeconds = 30)
@MethodRetry(maximumAttempts = 2, initialIntervalSeconds = 1, expirationSeconds = 30, maximumIntervalSeconds = 30)
String getGreetingContentOverTheWeb(URL url) throws IOException;
对于上面的 activity 我希望如果它失败应该自动重试,下面是我如何调用它
@Override
public String getGreeting(String name) {
// This is a blocking call that returns only after the activity has completed.
try {
String content = activities.getGreetingContentOverTheWeb(new URL("http://localhost:3000/import-map/books"));
return activities.composeGreeting(content, name);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return activities.composeGreeting("Hello", name);
}
如果我在这里做错了什么,请告诉我,
下面是前端的截图
从事件历史来看,activity 似乎被重试了。我通过查看 ActivityTaskStarted.attempt
字段来确定它。那里的数字等于重试次数。因此 activity 根据指定的重试策略恰好执行了两次请求。
我知道这个名字非常令人困惑,因为尝试应该从 1 而不是从 0 开始。我们已经 fixed this in the temporal.io 我的团队维护的 Cadence 分支。