diff --git a/build.gradle b/build.gradle index a833ff3cd..6c5da619d 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' 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(); } } }