私はResponseEntity<List<Attachment>>
を返すサービスメソッドを持ち、そのヒストリームfallback
メソッドもResponseEntity<List<Attachment>>
を返す必要があります。
問題は、私は新しいArraylist<>()
返すのではなく、ユーザーにエラーを明確に文字列メッセージを返す必要があるということです - ここに私の方法Spring MVC ResponseEntity Hystrixフォールバック
@Override
@HystrixCommand(fallbackMethod = "getAttachmentsFallback")
public ResponseEntity<List<AttachmentDto>> getAttachments(IAttachable entity) {
List<AttachmentDto> attachments = client.getAttachments(entity.getAttachableId(), entity.getClassName(),
entity.getAppName());
return new ResponseEntity<List<AttachmentDto>>(attachments, HttpStatus.OK);
}
であり、それは、そのフォールバックだ
public ResponseEntity<List<AttachmentDto>> getAttachmentsFallback(IAttachable entity, Throwable e) {
//I need to return a String instead of the new Arraylist<AttachmentDto>()
return new ResponseEntity<List<AttachmentDto>>(new ArrayList<AttachmentDto>(), HttpStatus.INTERNAL_SERVER_ERROR);
}