Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand All @@ -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();
}
}
}
Loading