Skip to content
v2.278.0

RetryProps Struct ​

Retry details.

Example ​

ts
const parallel = new sfn.Parallel(this, 'Do the work in parallel');

// Add branches to be executed in parallel
const shipItem = new sfn.Pass(this, 'ShipItem');
const sendInvoice = new sfn.Pass(this, 'SendInvoice');
const restock = new sfn.Pass(this, 'Restock');
parallel.branch(shipItem);
parallel.branch(sendInvoice);
parallel.branch(restock);

// Retry the whole workflow if something goes wrong with exponential backoff
parallel.addRetry({
  maxAttempts: 1,
  maxDelay: Duration.seconds(5),
  jitterStrategy: sfn.JitterType.FULL,
});

// How to recover from errors
const sendFailureNotification = new sfn.Pass(this, 'SendFailureNotification');
parallel.addCatch(sendFailureNotification);

// What to do in case everything succeeded
const closeOrder = new sfn.Pass(this, 'CloseOrder');
parallel.next(closeOrder);
python
parallel = sfn.Parallel(self, "Do the work in parallel")

# Add branches to be executed in parallel
ship_item = sfn.Pass(self, "ShipItem")
send_invoice = sfn.Pass(self, "SendInvoice")
restock = sfn.Pass(self, "Restock")
parallel.branch(ship_item)
parallel.branch(send_invoice)
parallel.branch(restock)

# Retry the whole workflow if something goes wrong with exponential backoff
parallel.add_retry(
    max_attempts=1,
    max_delay=Duration.seconds(5),
    jitter_strategy=sfn.JitterType.FULL
)

# How to recover from errors
send_failure_notification = sfn.Pass(self, "SendFailureNotification")
parallel.add_catch(send_failure_notification)

# What to do in case everything succeeded
close_order = sfn.Pass(self, "CloseOrder")
parallel.next(close_order)
java
Parallel parallel = new Parallel(this, "Do the work in parallel");

// Add branches to be executed in parallel
Pass shipItem = new Pass(this, "ShipItem");
Pass sendInvoice = new Pass(this, "SendInvoice");
Pass restock = new Pass(this, "Restock");
parallel.branch(shipItem);
parallel.branch(sendInvoice);
parallel.branch(restock);

// Retry the whole workflow if something goes wrong with exponential backoff
parallel.addRetry(RetryProps.builder()
        .maxAttempts(1)
        .maxDelay(Duration.seconds(5))
        .jitterStrategy(JitterType.FULL)
        .build());

// How to recover from errors
Pass sendFailureNotification = new Pass(this, "SendFailureNotification");
parallel.addCatch(sendFailureNotification);

// What to do in case everything succeeded
Pass closeOrder = new Pass(this, "CloseOrder");
parallel.next(closeOrder);
csharp
// Install: dotnet add package Amazon.CDK.Lib
var parallel = new Parallel(this, "Do the work in parallel");

// Add branches to be executed in parallel
var shipItem = new Pass(this, "ShipItem");
var sendInvoice = new Pass(this, "SendInvoice");
var restock = new Pass(this, "Restock");
parallel.Branch(shipItem);
parallel.Branch(sendInvoice);
parallel.Branch(restock);

// Retry the whole workflow if something goes wrong with exponential backoff
parallel.AddRetry(new RetryProps {
    MaxAttempts = 1,
    MaxDelay = Duration.Seconds(5),
    JitterStrategy = JitterType.FULL
});

// How to recover from errors
var sendFailureNotification = new Pass(this, "SendFailureNotification");
parallel.AddCatch(sendFailureNotification);

// What to do in case everything succeeded
var closeOrder = new Pass(this, "CloseOrder");
parallel.Next(closeOrder);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
parallel := sfn.NewParallel(this, jsii.String("Do the work in parallel"))

// Add branches to be executed in parallel
shipItem := sfn.NewPass(this, jsii.String("ShipItem"))
sendInvoice := sfn.NewPass(this, jsii.String("SendInvoice"))
restock := sfn.NewPass(this, jsii.String("Restock"))
parallel.Branch(shipItem)
parallel.Branch(sendInvoice)
parallel.Branch(restock)

// Retry the whole workflow if something goes wrong with exponential backoff
parallel.AddRetry(&RetryProps{
	MaxAttempts: jsii.Number(1),
	MaxDelay: awscdk.Duration_Seconds(jsii.Number(5)),
	JitterStrategy: sfn.JitterType_FULL,
})

// How to recover from errors
sendFailureNotification := sfn.NewPass(this, jsii.String("SendFailureNotification"))
parallel.AddCatch(sendFailureNotification)

// What to do in case everything succeeded
closeOrder := sfn.NewPass(this, jsii.String("CloseOrder"))
parallel.Next(closeOrder)

Properties ​

backoffRateoptionalnumberbackoff_rateoptionalint | floatbackoffRateoptionalNumberBackoffRateoptionaldoubleBackoffRateoptional*float64 = 2 #
Multiplication for how much longer the wait interval gets on every retry.
errorsoptionalstring[]errorsoptionaltyping.List[str]errorsoptionalList<String>Errorsoptionalstring[]Errorsoptional*[]*string #
Errors to retry.

Default: All errors

A list of error strings to retry, which can be either predefined errors (for example Errors.NoChoiceMatched) or a self-defined error.

intervaloptionalDurationintervaloptionalDurationintervaloptionalDurationIntervaloptionalDurationIntervaloptionalDuration = Duration.seconds(1) #
How many seconds to wait initially before retrying.
jitterStrategyoptionalJitterTypejitter_strategyoptionalJitterTypejitterStrategyoptionalJitterTypeJitterStrategyoptionalJitterTypeJitterStrategyoptionalJitterType #
Introduces a randomization over the retry interval.

Default: No jitter strategy

maxAttemptsoptionalnumbermax_attemptsoptionalint | floatmaxAttemptsoptionalNumberMaxAttemptsoptionaldoubleMaxAttemptsoptional*float64 = 3 #
How many times to retry this particular error.

May be 0 to disable retry for specific errors (in case you have a catch-all retry policy).

maxDelayoptionalDurationmax_delayoptionalDurationmaxDelayoptionalDurationMaxDelayoptionalDurationMaxDelayoptionalDuration #
Maximum limit on retry interval growth during exponential backoff.

Default: No max delay