package Ġio . github . vol k ano z kan . res il ience 4 j demo . business . controller Ċ Ċ import Ġio . github . res il ience 4 j . circuit break er . Call Not Per mitted Exception Ċ import Ġio . github . res il ience 4 j . rate limiter . Request Not Per mitted Ċ import Ġio . github . vol k ano z kan . res il ience 4 j demo . business . service . Service Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . web . bind . annotation . ExceptionHandler Ċ import Ġorg . springframework . web . bind . annotation . GetMapping Ċ import Ġorg . springframework . web . bind . annotation . RequestMapping Ċ import Ġorg . springframework . web . bind . annotation . RestController Ċ Ċ @ RestController Ċ @ RequestMapping ("/ v 1 / api ") Ċ class ĠResource ( private Ġval Ġservice : ĠService ) Ġ{ ĊĊĠĠĠ Ġ@ GetMapping ("/ rl ") ĊĠĠĠ Ġfun Ġcall With Rate Limiter (): ĠResponseEntity < String > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġservice . call With Rate Limiter () ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( result ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ("/ cb ") ĊĠĠĠ Ġfun Ġcall With Circuit Breaker (): ĠResponseEntity < String > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġservice . call With Circuit Breaker () ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( result ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ ExceptionHandler ( Request Not Per mitted :: class ) ĊĠĠĠ Ġfun Ġexception Handler ( exception : ĠRequest Not Per mitted ): ĠResponseEntity < String > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . status ( HttpStatus . TOO _ MAN Y _ REQUEST S ). body (" Reached Ġthe Ġrate Ġlimit Ġfor Ġthis Ġapi .") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ ExceptionHandler ( Call Not Per mitted Exception :: class ) ĊĠĠĠ Ġfun Ġexception Handler ( exception : ĠCall Not Per mitted Exception ): ĠResponseEntity < String > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . status ( HttpStatus . NOT _ ACCEPT ABLE ). body (" Circuit ĠBreak er Ġis Ġnot Ġallowing Ġmore Ġcalls .") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ ExceptionHandler ( IllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġexception Handler ( exception : ĠIllegalArgumentException ): ĠResponseEntity < String > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . status ( HttpStatus . BAD _ REQUEST ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. body (" Received ĠIllegal ĠArgument ĠException . ĠCircuit Ġbreak er Ġis Ġstill Ġclosed Ġand Ġallows Ġfor Ġmore Ġcall .") ĊĠĠĠ Ġ} Ċ }