1

SNS イベントを処理する AWS Lambda で実行されている Spring Cloud Function があります。いくつかのエラー ケースでは、自動 Lambda 再試行をトリガーするか、SNS サービスの再試行機能をトリガーしたいと考えています。SNS 再試行ポリシーはデフォルト設定です。

{"statusCode":500} で JSON を返そうとしました。これは、aws コンソールでテスト呼び出しを行うときに機能しています。とにかく、このステータスを送信すると、関数の呼び出しの再試行はトリガーされません。

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;
    }
}
4

1 に答える 1