From 5bdf09fefae7485aef8fbedf97e6736d501391c2 Mon Sep 17 00:00:00 2001 From: Quinn Klassen Date: Thu, 19 Jun 2025 08:35:35 -0700 Subject: [PATCH 1/2] Switch poller sample to use ApplicationErrorCategory --- build.gradle | 2 +- .../InfrequentPollingActivityImpl.java | 13 ++++++++++--- ...quentPollingWithRetryAfterActivityImpl.java | 18 +++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index a833ff3cd..ea43b6350 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ subprojects { ext { otelVersion = '1.30.1' otelVersionAlpha = "${otelVersion}-alpha" - javaSDKVersion = '1.28.1' + javaSDKVersion = '1.30.0-RC1' camelVersion = '3.22.1' jarVersion = '1.0.0' } diff --git a/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingActivityImpl.java b/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingActivityImpl.java index 5b9a5b0cd..1bca960a9 100644 --- a/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingActivityImpl.java +++ b/core/src/main/java/io/temporal/samples/polling/infrequent/InfrequentPollingActivityImpl.java @@ -1,11 +1,12 @@ package io.temporal.samples.polling.infrequent; -import io.temporal.activity.Activity; +import io.temporal.failure.ApplicationErrorCategory; +import io.temporal.failure.ApplicationFailure; import io.temporal.samples.polling.PollingActivities; import io.temporal.samples.polling.TestService; public class InfrequentPollingActivityImpl implements PollingActivities { - private TestService service; + private final TestService service; public InfrequentPollingActivityImpl(TestService service) { this.service = service; @@ -17,7 +18,13 @@ public String doPoll() { return service.getServiceResult(); } catch (TestService.TestServiceException e) { // We want to rethrow the service exception so we can poll via activity retries - throw Activity.wrap(e); + throw ApplicationFailure.newBuilder() + .setMessage(e.getMessage()) + .setType(e.getClass().getName()) + .setCause(e) + // This failure is expected so we set it as benign to avoid excessive logging + .setCategory(ApplicationErrorCategory.BENIGN) + .build(); } } } diff --git a/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterActivityImpl.java b/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterActivityImpl.java index a202e0b71..2de6a7731 100644 --- a/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterActivityImpl.java +++ b/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/InfrequentPollingWithRetryAfterActivityImpl.java @@ -1,6 +1,7 @@ package io.temporal.samples.polling.infrequentwithretryafter; import io.temporal.activity.Activity; +import io.temporal.failure.ApplicationErrorCategory; import io.temporal.failure.ApplicationFailure; import io.temporal.samples.polling.PollingActivities; import io.temporal.samples.polling.TestService; @@ -10,7 +11,7 @@ import java.time.format.DateTimeFormatter; public class InfrequentPollingWithRetryAfterActivityImpl implements PollingActivities { - private TestService service; + private final TestService service; final DateTimeFormatter ISO_FORMATTER = DateTimeFormatter.ISO_DATE_TIME; public InfrequentPollingWithRetryAfterActivityImpl(TestService service) { @@ -32,13 +33,16 @@ public String doPoll() { // which is the test service exception // and delay which is the interval to next retry based on test service retry-after directive System.out.println("Activity next retry in: " + e.getRetryAfterInMinutes() + " minutes"); - throw ApplicationFailure.newFailureWithCauseAndDelay( - e.getMessage(), - e.getClass().getName(), - e, - // here we set the next retry interval based on Retry-After duration given to us by our + throw ApplicationFailure.newBuilder() + .setMessage(e.getMessage()) + .setType(e.getClass().getName()) + .setCause(e) + // Here we set the next retry interval based on Retry-After duration given to us by our // service - Duration.ofMinutes(e.getRetryAfterInMinutes())); + .setNextRetryDelay(Duration.ofMinutes(e.getRetryAfterInMinutes())) + // This failure is expected so we set it as benign to avoid excessive logging + .setCategory(ApplicationErrorCategory.BENIGN) + .build(); } } } From 9186f15d86155e26922301a3aa5c0b7633059220 Mon Sep 17 00:00:00 2001 From: Quinn Klassen Date: Tue, 24 Jun 2025 16:39:46 -0700 Subject: [PATCH 2/2] point to a released version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ea43b6350..6c5da619d 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ subprojects { ext { otelVersion = '1.30.1' otelVersionAlpha = "${otelVersion}-alpha" - javaSDKVersion = '1.30.0-RC1' + javaSDKVersion = '1.30.0' camelVersion = '3.22.1' jarVersion = '1.0.0' }