Reputation: 78
I have a Spring Cloud Function running on AWS Lambda handling SNS Events. For some error cases I would like to trigger automatic Lambda retries or triggerthe retry capabilities of the SNS Service. SNS Retry Policies are in default configuration.
I tried to return a JSON with {"statusCode":500}, which is working when we make a test invokation in the aws console. Anyway when we send this status, no retry invokation of the Function is triggered.
We use the SpringBootRequestHandler
public class CustomerUpdatePersonHandler extends SpringBootRequestHandler<SNSEvent, Response> {
}
@Component
public class CustomerUpdatePerson implements Function<SNSEvent, Response> {
@Override
public Response apply(final SNSEvent snsEvent) {
//when something goes wrong return 500 and trigger a retry
return new Response(500)
}
}
public class Response{
private int statusCode;
public Response(int code){
this.statusCode = code;
}
public int getStatusCode(){
retrun statusCode;
}
}
Upvotes: 1
Views: 439
Reputation: 6126
We currently don't provide support for retry, but given that every function is transformed to reactive function anyway you can certainly do it yourself if you declare your function using reactor API. Basically Function<Flux<SNSEvent>, Flux<Response>>
and then you can use one of the retry operations available (e.g., retryBackoff
).
Upvotes: 0