retry, retryWhen, repeat
retry()
Use this operator to retry failed exceptions
When to use it?
Code interacts with external systems through network
Examples are : RestFul API calls, DB Calls
these calls may fail intermittently

์๋ฌ๊ฐ ๋ฐ์ํ๋ฉด ๋ฌดํํ ๋ค์ subscribe()๋ฅผ ์๋ํ๋ค. onComplete() ์ ๋ฐ์ง ๋ชปํ๋ค๋ฉด ๋์์ด subscribe()๋ฅผ ๋ค์ ์๋ํ๋ค.
๋ฐ๋ฉด์ ์๋์ ๊ฐ์ด parameter๋ก retry count๋ฅผ ๋ฃ์ด์ฃผ๋ฉด ์ ํด์ค count ๋งํผ๋ง retry๋ฅผ ์๋ํ๋ค.

retryWhen()

retryWhen์ ๊ณต์ ๋ฌธ์์ ์ค๋ช ์ด ๋๋ฌด ๊ธธ์ด์ ๋ง๋ธ ๋ค์ด์ด๊ทธ๋จ๋ง ๋ฐ์ทํด ์๋ค. retry๋ฅผ ๋ฌด์์ ํ์ง ์๊ณ retrySpec์ ์๊ฑฐํ์ฌ retry ๋ฅผ ํ๋ค๋ ๊ฒ์ด ํน์ง์ด๋ค. ์ฌ์ค ์ค๋ฌด์์๋ retry ๋ณด๋ค retryWhen ์ ์ธ ๊ฐ๋ฅ์ฑ์ด ํฌ๋ค๊ณ ํ๋จ๋๋ค. ํนํ ์ ์์ ์ธ ์์ฒญ์ ๋ํด์ ์๋ ์๋ฒ๊ฐ ๊ฐํ์ ์ผ๋ก ์ด์ํ ๊ฐ์ ๋ด๋ ค์ค๋ค๋ฉด ์ด๋ฅผ ์กฐ๊ฑด์ ์ผ๋ก ํ๋จํด์ retry ํด์ฃผ๋ ๋ก์ง์ด ํ์ํ๋ฏ๋ก ๊ทธ ๋ ์ฌ์ฉํ๋ฉด ์ข๋ค.
repeat()
Used to repeat an existing sequence
This operator gets invoked after the onCompletion() event from the existing sequence
Use it when you have an use-case to subscribe to same publisher again
This operator works as long as No Exception is thrown

๋ค์ ๊ตฌ๋ (=๋ฐ๋ณต)์ ํ๊ธฐ ์ํ ์ฐ์ฐ์์ด๋ค. ๊ฐ์์์๋ ์ค๋ช ํ๊ณ ์๊ณ , ๊ณต์ ๋ฌธ์์๋ ๋์์๋ฏ์ด onComplete() ์ด ์คํ๋์ด์ผ๋ง ๋ฐ๋ณต ๊ตฌ๋ ์ ์คํํ๋ค. retry() ์ ๋ง์ฐฌ๊ฐ์ง๋ก parameter๋ฅผ ๋ฃ์ด์ฃผ์ง ์์ผ๋ฉด ๋ฌดํํ ๋ฐ๋ณตํ๊ณ parameter๋ก ๋ฐ๋ณต ํ์๋ฅผ ์ ํ ํ ์ ์๋ค.
๋น์ฐํ ์ด์ผ๊ธฐ์ด์ง๋ง ๊ตฌ๋ ์ค์ ์๋ฌ๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ repeat์ ๋์ํ์ง ์๋๋ค. repeat ์ด onComplete() ์ดํ ์คํ๋๋ค๋ ๊ฒ์ ์๊ฐํด๋ด๋ ๊ทธ๋ ๊ณ , ๊ตฌ๋ ์ค ์๋ฌ๊ฐ ๋ฐ์ํ๋ฉด repeat ์ฐ์ฐ์๋ฅผ ๋ง๋๊ธฐ ์ ์ ์ด๋ฏธ ๊ตฌ๋ ํ๋ฆ์ด ์ค๋จ๋์ด๋ฒ๋ฆฐ๋ค๋ ๊ฒ์ ์๊ฐํด๋ด๋ ์ด๊ฒ์ด ์ด์น์ ๋ง๋ค๊ณ ์ธ์ํ ์ ์๋ค.
Last updated