Cloud Stream Configuration
๊ฐ์
์ด์ ์ ์คํ๋ง ํด๋ผ์ฐ๋ ์คํธ๋ฆผ์ ๋ํด ์์๋ณด์์๋ค. ๊ทธ๋ ๋ค๋ฉด ์ค์ ์๋น์ค ์ ์ฉ์ ์ํด ์ด๋ค ๊ฐ์ ์ค์ ํ๊ณ , ์ด๋ป๊ฒ ๋์์ด ๋๋์ง ์์๋ณด์.
Cloud Stream Properties
Spring Cloud Stream(์ดํ SCS)์์๋ ๋ฐ์ธ๋ฉ ๊ด๋ จ ๊ตฌ์ฑ์ ์๋ํํ๊ธฐ ์ํด ๋ค์์ ๊ณผ์ ์ผ๋ก ์งํํ ์ ์๋ค.
- ์ฐ๊ฒฐ ํ ํจ์ ์ ์(
spring.cloud.function) - Cloud Stream ๋ ๋ฒจ์ ์ถ์ํ ๋ฐ์ธ๋ฉ ์ ์(
spring.cloud.stream.bindings) - ๋ฉ์์ง ํ๋ซํผ ๋ฐ์ธ๋ ์ค์ (
spring.cloud.stream.{name})
1. ์ฐ๊ฒฐ ํจ์ ์ ์
definition ํ๋กํผํฐ(์ดํ definition)๋ ํจ์๋ฅผ ์ ์ํ๋ค.
์ ํํ๋ ํจ์์ ์ด๋ฆ, ํ์ดํ๋ผ์ธ์ ์ ์ ํ๋ค. ํ๋ ์์ํฌ ๋ด๋ถ์ ์ผ๋ก definition์ด ํด์๋ ๋ ๋ ๊ฐ์ง์ ๋ฐฉ๋ฒ์ผ๋ก ์ ์ํ ์ ์๋ค.
SCS์์๋ ์ถ์ํ๋ ํจ์๋ฅผ ๊ธฐ์ฐจ๋์ด์ฒ๋ผ ์ฌ๋ฌ๊ฐ๋ฅผ ๋ถ์ฌ์ ํ๊ฐ์ ํจ์๋ก ๋ง๋ค์ ๋ ์๊ณ , ๋
๋ฆฝ์ ์ผ๋ก ํ๊ฐ์ ํจ์๋ง ๊ทธ๋๋ก ์ฌ์ฉํ ์ ์๋ค.
;๋ก ๊ตฌ๋ถ๋๋ค๋ ๊ฒ์ด๋ค.
๋ ๋ฆฝ์ ์ผ๋ก ํ๊ฐ์ ํจ์๋ง ์ ์ํ๊ธฐ
spring:
cloud:
funtion:
definition: create-schedule;์ ๊ฒฝ์ฐ ์ค์ผ์ค ์์ฑ(create-schedule)์ด๋ผ๋ ๋
๋ฆฝ์ ์ธ ํ๊ฐ์ ํจ์๋ง ๋์ํ๋ค.
ํจ์ ํ์ดํ๋ผ์ธ์ ๊ตฌ์ฑํ์ฌ ํ๊ฐ์ ํจ์๋ฅผ ์ ์ํ๊ธฐ
spring:
cloud:
function:
definition: create-schedule|alert-operation;ํจ์ ํ์ดํ๋ผ์ธ์ ๊ตฌ์ฑํ๋ ค๋ฉด, |ํ์ดํ ๋ฌธ์์ด(, ์ผํ๋ ๊ฐ๋ฅ)๋ก ํจ์์ ์ ์๋ฅผ ๋ฌถ์ด ์ ์ํ ์์๋ค.
๋จ์ผ ํจ์
โญโโโโ Function โโโโฎ
โ create-schedule โ
โฐโโโโโโโโโโโโโโโโโโฏ
ํ์ดํ๋ผ์ธ ํจ์
โญโโโ Function1 โโโโฎ โญโโโ Function2 โโโโฎ
โ create-schedule โ โโ โ alert-operation โ
โฐโโโโโโโโโโโโโโโโโโฏ โฐโโโโโโโโโโโโโโโโโโฏ
ํ์ดํ๋ผ์ธ ํจ์๋ ์ฒ๋ฆฌํ ํจ์์ ์ถ๋ ฅ๊ฐ๊ณผ ๋ค์ ํจ์์์ ๋ฐ์ ์ ๋ ฅ๊ฐ์ด ๊ฐ์์ผํ๋ค. ๊ทธ๋ ๋ค๋ฉด ์ฌ๋ฌ ์ข ๋ฅ์ ํจ์๋ฅผ ์ ์ํ๋ ค๋ฉด ์ด๋ป๊ฒ ํ ์ ์์๊น?
spring:
cloud:
function:
definition: create-schedule|alert-operation; modify-schedule
;)๋ ์๋ค๋ก ๊ณต๋ฐฑ์ด ์์ด๋ ๋์ง๋ง, ํ์ดํ๋ผ์ธ ๊ตฌ๋ถ์(|)๋ ์, ๋ค๋ก ๊ณต๋ฐฑ์ด ์์ผ๋ฉด ์๋๋ค.
๋ํ, spring.cloud.function.routing.enabled ์ต์
์ด ํ์ฑ๋ ๋๋ค๋ฉด definition์ด functionRouter๋ก ๋ฎ์ด์จ์ง๊ธฐ ๋๋ฌธ์ ์ ์ฉ๋์ง ์๋๋ค.
;)๋ ๊ตฌ๋ถ์ ์ฐ์ด๊ธฐ ๋๋ฌธ์, create-schedule|alert-operation; modify-schedule;์ฒ๋ผ ์ค์ ํ๋ฉด
์ค์ ๋ก ๊ตฌ์ฑ์์ ["create-schedule|alert-operation", "modify-schedule", ""] ์ฒ๋ผ 3 ๊ฐ์ ์ค์ ์ผ๋ก ์ธ์๋๋ค. ๋ฐ๋ผ์ ์ฃผ์๊ฐ ํ์ํ๋ค.
2. ์ถ์ํ ๋ฐ์ธ๋ฉ ์ ์
๋จผ์ ์ถ์ํ ๋ฐ์ธ๋ฉ์ด ๋ญ์ง ๊ฐ๋จํ๊ฒ ์ง๊ณ ๋์ด๊ฐ์๋ฉด, ๋ค์๊ณผ ๊ฐ๋ค.
- SCS๋ ๋ง์ ๋ฉ์์ง ํ๋ซํผ์ ์ง์ํ์ง๋ง, ์ค์ ๊ทธ ๊ตฌํ๊น์ง๋ ๊ด์ฌํ์ง ์์.
- SCS๋ ๊ฐ ๊ตฌํ์ฒด์ธ Binder์ ์ ์ด ๋๊ธฐ๊ธฐ ์ ๊น์ง ์คํ๋ง์ ๊ตฌ์ฑ๋ ํจ์ํ ์ปดํฌ๋ํธ์ ์ฐ๊ฒฐ๋๋ ๋ฐ์ธ๋ฉ์ ์ค์ ๊ธฐ๋ฐ์ผ๋ก ์ค๋นํจ.
๋ฉ์ธ์ง ํ๋ซํผ๊ณผ ์ฐ๊ฒฐ๋๋ ค๋ฉด ๊ฐ Binder(RabbitMQ, Kafka)๋ค๊ณผ ์ฐ๊ฒฐ๋๋ ์์๋ ๋ฒจ ๊ตฌ์ฑ์ด ํ์ํ๊ณ , ์ด๋ฅผ SCS๊ฐ ์ ๊ณตํ๋ค.
โญโโโโโโโโโโโโฎ โญโโโโโโโโโโโโโฎ
โ Funtion 1 โ โ Function 2 โ
โฐโโโโโโโโโโโโฏ โฐโโโโโโโโโโโโโฏ
โโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโ
โญโโโโโโโโ Function โโโโโโโโโฎ
โ Spring Cloud Stream โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โโโโโโคโโโโโโโโโโโโโโโโโโคโโโโโโโ
โโ โโ
โญโ Kafka โโฎ โญโโโ Rabbit MQ โโโโฎ
โ Topic โ โ Exchange, Queue โ
โฐโโโโโโโโโโฏ โฐโโโโโโโโโโโโโโโโโโฏ
spring:
cloud:
function:
definition: create-schedule; modify-schedule
stream:
#SCS ์ถ์ํ๋ฅผ ์ํ ๋ฐ์ธ๋ฉ
bindings:
create-schedule-in-0:
destination: schedule-consume-exchange
group: create-schedule-queue
modify-schedule-in-0:
destination: schedule-consume-exchange
group: modify-schedule-queue
SCS์ ๋ฐ์ธ๋ฉ ์ถ์ํ๋ ์ค์ ๊ทธ ๋ฐ์ธ๋ฉ๋์์ด ์ด๋ค ๋ฐฉํฅ(์์ฐ ๋๋ ์๋น)์ธ์ง ๋ชจ๋ฅด๊ธฐ ๋๋ฌธ์, ๋ชจ๋ ์ค์ ์๋ํ ๊ตฌ์ฑ์ ๋ฐ๋๋ค.
์ถ๊ฐ์ ์ธ ์์ฑ์ ๋ฐ์ธ๋ฉ ์ ๋ณด๋ก์ ์ถ์ํ๋๋ฉฐ ์๋์ ๋ด์ฉ์ ํฌํจํ๋ค:
- destination: ๋ฐ์ธ๋๊ฐ ๋ฐ์ธ๋ํ๋ ๋ธ๋ก์ปค์์์ ๋ฌผ๋ฆฌ์ ์ธ ์ด๋ฆ์ ์๋ฏธํ๋ค.
RabbitMq์ ๊ฒฝ์ฐ Exchange์ ์ด๋ฆ์ผ๋ก, Kafka์ ๊ฒฝ์ฐ Topic์ ์ด๋ฆ์ผ๋ก ์ ์ํ๋ค.
- group
- ๊ทธ๋ฃน์ ๊ฒฝ์ฐ Consumer์๊ฒ๋ง ์ ์ฉ๋๋ฉฐ, ์์๋ ๋ฐ์ธ๋ฉ์ ๊ณ ์ ํ ์ด๋ฆ์ด๋ค. ๋ง์ ์ปจ์๋จธ๊ฐ ๊ฐ์ ๊ทธ๋ฃน ๋ด์์ ๊ตฌ๋ ์ ๊ณต์ ํ๋ค.
- null, ๋น ๋ฌธ์์ด ๊ฐ์ ์ต๋ช ๊ทธ๋ฃน์ ๋ํ๋ด๋ฉฐ ๊ณต์ ๋์ง์๋๋ค.
- ์ฆ ๊ทธ๋ฃน์ ๊ฐ ๋ฏธ๋ค์จ์ด์์ ์ปจ์๋จธ๋ฅผ ๋ฌถ๋ ๊ทธ๋ฃน์ผ๋ก ์ดํดํ๋ฉด ๋๋ค.
RabbitMQ์ ๊ฒฝ์ Queue,Kafka์ ๊ฒฝ์ฐ Consumer Group๊ณผ ์ฐ๊ฒฐ๋๋ค.
- contentType
- ์ด๋ฒคํธ ๋ด์์ ์ด ๋ฐ์ธ๋ฉ์ผ๋ก ์ฌ์ฉ๋ ์ฝํ
์ธ ์ ์ ํ์ ์๋ฏธํ๋ค. HTTP ์คํ์์ ์ฌ์ฉ๋๋ MIME Type๊ณผ ๋์ผํ๋ค. ๊ธฐ๋ณธ๊ฐ์
application/json - ๋ฉ์ธ์ง ํค๋์ ์ง์ ๋์ง ์์ ๊ฒฝ์ฐ ์ด ๋ฐ์ธ๋ฉ์์ ์ฌ์ฉ๋ ์ฝํ ์ธ ์ ํ์ ์ง์ ํ๋ค.
- ์ด๋ฒคํธ ๋ด์์ ์ด ๋ฐ์ธ๋ฉ์ผ๋ก ์ฌ์ฉ๋ ์ฝํ
์ธ ์ ์ ํ์ ์๋ฏธํ๋ค. HTTP ์คํ์์ ์ฌ์ฉ๋๋ MIME Type๊ณผ ๋์ผํ๋ค. ๊ธฐ๋ณธ๊ฐ์
- bindier
- ์ฌ๋ฌ๊ฐ์ ๋ฐ์ธ๋๊ฐ ์ฌ์ฉ ๊ฐ๋ฅํ ๊ฒฝ์ฐ ์ด ๋ฐ์ธ๋ฉ์์ ์ฌ์ฉํ ๋ฐ์ธ๋๋ช
- ์: rabbit
- consumer
- ์ถ๊ฐ์ ์ธ ์ปจ์๋จธ ํ๋กํผํฐ (
ConsumerProperties)
- ์ถ๊ฐ์ ์ธ ์ปจ์๋จธ ํ๋กํผํฐ (
- producer
- ์ถ๊ฐ์ ์ธ ํ๋ก๋์ ํ๋กํผํฐ (
ProducerProperties)
- ์ถ๊ฐ์ ์ธ ํ๋ก๋์ ํ๋กํผํฐ (
3. ๋ฉ์์ง ํ๋ซํผ ๋ฐ์ธ๋ ์ค์
SCS๋ ์ค์ ๋ฉ์์ง ํ๋ซํผ๊ณผ ์ ์ฐํ๊ฒ ์ฐ๊ฒฐ๋๊ธฐ ์ํด Binder์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํ๋ค.
๋ํ ๊ฐ ํ๋ซํผ ๋ฐ์ธ๋ ๋ชจ๋์ ์ด๋ฅผ ๊ตฌํํ์ฌ ๋ธ๋ก์ปค์ ํต์ ํ๋ฉฐ, ์ค์ ์คํธ๋ฆผ์ ์ ๊ณตํ๋ค.
์๋ฅผ ๋ค์ด RabbitMQ๋ผ๋ฉด ๋ค์๊ณผ ๊ฐ์ด ๊ตฌ์ฑํ ์ ์๋ค.
spring:
cloud:
function:
definition: create-schedule
stream:
#SCS ์ถ์ํ๋ฅผ ์ํ ๋ฐ์ธ๋ฉ
bindings:
create-schedule-in-0:
destination: create-schedule-exchange
group: create-schedule-queue
binder: rabbit
rabbit:
bindings:
create-schedule-in-0:
consumer:
auto-bind-dlq: false
create-schedule(์ค์ผ์ค ์์ฑ)์ ๊ฒฝ์ฐ DLQ(Dead Letter Queue)๋ฅผ ์ค์ ํ์ง ์๊ณ Exchange์ Queue๋ง ์ง์ ํด์ฃผ์๋ค.
SCS์์๋ ์ฑ๋์ ์ด๋ฆ(*-out-0, *-in-0)์ด ์ฝ์๋์ด์๊ธฐ ๋๋ฌธ์, ์ด๋ฆ์ ์ํด ์ปค์คํ
์ค์ ์ ํ์ง์๋ ์ด์ ๋ค์ด๋ฐ ์ปจ๋ฒค์
์ ๋ฐ๋ผ์ผํ๋ค.
์ปจ์๋จธ(Consumer)๋ ๊ธฐ๋ณธ์ ์ผ๋ก *-in-0๋ฃฐ์ ๋ฐ๋ฅด๊ธฐ ๋๋ฌธ์ ์์ ๊ฐ์ด ์ง์ ํ์๋ค.
BindingFunctionProxyFactory#buildInputNameForIndex(int)์์ ํ์ธํ ์ ์๋ค.
โญโโโโโโโโ Exchange โโโโโโโโโฎ
โ create-schedule-exchange โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โ โโ โ
โญโโโโโโโ Queue โโโโโโโโโโฎ
โ create-schedule-queue โ
โฐโโโโโโโโ//โโโ\\โโโโโโโโโฏ
// \\
โญโโโโโโฎ โญโโโโโโฎ
โ App โ โ App โ
โฐโโโโโโฏ โฐโโโโโโฏ
์ ๋ฐ์ธ๋ฉ์ ํ๋ฆ์ ๊ฐ๋ตํ ๋ณธ๋ค๋ฉด ์์ ๊ฐ๋ค App์์๋ ์ฒ๋ฆฌํ ๋ฉ์ธ์ง์ Exchange ์ ๋ณด๋ฅผ ์ ์(App ๊ตฌ๋์ ๋์ผํ ์ ๋ณด๊ฐ ์๋ค๋ฉด ์์ฑ)ํ๋ค.
auto-bind-dlq ์ต์
์ ํ์ฑํ ํ๋ฉด ๊ธฐ๋ณธ์ ์ผ๋ก Dead Letter๋ฅผ ์ฒ๋ฆฌํ ์ ์๋
Exchange๋ฅผ DLX๋ก ์ฌ์ฉ(์์ผ๋ฉด ์์ฑ)ํ๋ค.
์ ์ด๋ฏธ์ง๋ auto-bind-dlq ์ต์
์ ํตํด DLQ ๋ฐ์ธ๋ฉ์ ์งํํ์๋ค. DLX๋ dead-letter-exchange ์ต์
์ผ๋ก dlq ์ด๋ฆ์ ์ง์ ํ์ง ์๋์ด์, ๊ธฐ๋ณธ์ผ๋ก ์ฌ์ฉ๋๋ค.
์ด๋ ๋ค๋ฅธ ํ๋ค๊ณผ ํจ๊ป DLX๊ฐ ๊ณต์ ๋๋ฉฐ Queue์ ์ด๋ฆ์ด Routing Key๋ก ์ฌ์ฉ๋๋ค.
๊ฐ ๋ฐ์ธ๋์์๋ ์ถ์ํ๋ ์ค์ ์ ๊ตฌํํ๊ธฐ ๋๋ฌธ์, spring.cloud.streamํ์์ ๊ฐ๋ณ ์ค์ ์ ๋ค์์ Properties๋ฅผ ์ฐธ๊ณ ํ์ฌ ์ค์ ํ ์ ์๋ค:
RabbitMQ: RabbitExtendedBindingProperties.classKafka: KafkaExtendedBindingProperties.class
์ฌ๋ฌ ํจ์๋ฅผ ๊ฒฐํฉํ๊ธฐ ์ํ ๋ฐฉ๋ฒ์ ํจ์ ์ค์ ์์ ์ ์ธํ ์ ์๋ค.
์ค์ ๊ธฐ๋ฐ ๋ด๋ถ ๋์
SCS์ ๋ค์ํ ๊ตฌ์ฑ์ ์ถ์ํ ํ๊ธฐ ์ํด ๋ด๋ถ์ ์ผ๋ก ์ฌ๋ฌ ์ค์ ๋ค์ด ์ด๋ฃจ์ด์ง๋ค.
spring:
cloud:
function:
definition: >
create-schedule,alert-operation;
create-user
stream:
bindings:
create-schedule,alert-schedule-in-0:
destination: create-schedule-exchange
group: create-schedule-queue
binder: rabbit
...
๋ง์ฝ ์์ ๊ฐ์ ์ค์ ์ผ๋ก ์ ์ฉ๋๋ค๋ฉด, ์ค์ ๋ฉ์ธ์ง ๋ธ๋ก์ปค์ ์ ์ฐ๊ฒฐ์ด ์ด๋ฃจ์ด์ง๊ธฐ ๊น์ง ๋ค์์ ๊ณผ์ ์ ๊ฑฐ์น๋ค:
Created! Created!
โญโโ Function Bean โโโฎ โญโ Function Bean โโฎ
โ (create-schedule) โ โ alert-schedule โ
โฐโโโโโโโโโโโโโโโโโโโโฏ โฐโโโโโโโโโโโโโโโโโโฏ์ ์ฒ๋ฆฌ๋ฅผ ์งํํ๊ธฐ ์ํด FunctionConfiguration์์ ์ค์ ํ์ฌ ์ถ์ํ ํจ์๋ฅผ ๋ฐ์ธ๋ฉ ํ๋ BindableFunctionProxyFactory๋ฅผ ์์ฑํ๋ค.
๋จผ์ ์ค์ ์ ์๋์ ๊ฐ์ด ํจ์ ๋จ์๋ก ์งํํ๋ค:
@Override
public void afterPropertiesSet() throws Exception {
//spring.cloud.function.definition ํ๋กํผํฐ๋ก ํจ์์ด๋ฆ ๊ฒฐ์ .
//spring.cloud.stream.function.routing.enabled ํ์ฑํ ์ ๋ชจ๋ functionRouter๋ก ๋ฎ์ด์จ์ง
this.determineFunctionName(functionCatalog, environment);
if (StringUtils.hasText(streamFunctionProperties.getDefinition())) {
String[] functionDefinitions = this.filterEligibleFunctionDefinitions();
//funtionDefinition = "create-schedule,alert-schedule"
for (String functionDefinition : functionDefinitions) {
//ํจ์ ์กฐํ
FunctionInvocationWrapper function = functionCatalog.lookup(functionDefinition);
if (function != null) {
if (function.isSupplier(
...
AtomicReference<BindableFunctionProxyFactory> proxyFactory = new AtomicReference<>();
...
//"create-schedule,alert-schedule_binding"์ผ๋ก Bean ๋ฑ๋ก
((GenericApplicationContext) this.applicationContext).registerBean(functionDefinition + "_binding",
BindableFunctionProxyFactory.class, proxyFactory::get);
}
else {
logger.warn("The function definition '" + streamFunctionProperties.getDefinition() +
"' is not valid. The referenced function bean or one of its components does not exist");
}
}
}
this.createStandAloneBindingsIfNecessary(applicationContext.getBean(BindingServiceProperties.class));
}
์ฌ๊ธฐ์ functionDefinition + "_binding"์ด๋ผ๊ณ ๋ฑ๋ก๋ BindableFunctionProxyFactory๋ฅผ ๋ฐ์ธ๋ฉ ๋น์ด๋ผ๊ณ ํ๋ค.
๋ฐ์ธ๋ฉ ๋น์ ๋ฐ์ธ๋ฉ์ ์ํด ํ์ํ ์ ๋ณด๋ฅผ ๊ฐ๊ณ ์๊ณ , ์ธ๋ถ์์ createAndBindInputs์ผ๋ก ์ปจ์๋จธ ๋ฐ์ธ๋ฉ์, createAndBindOutputs์ผ๋ก ํผ๋ธ๋ฆฌ์
๋ฐ์ธ๋ฉ์ ํธ์ถํ ์์๋๋ก ์ ๊ณตํ๋ค.
์์์ ์๊ฐ ํ๋ ๊ฐ ์ญํ ์ ๋์ดํด ๋ณด๋ฉด ๋ค์๊ณผ ๊ฐ๋ค:
โญโ DefaultLifecycleProcessor โโโโโโโโโโโโโโโโโโโโโฎ
โโญโ Binding Lifecycle Bean Start โโโโโโโโโโโโโโโโฎโ
โโ โญโ Bindable (Create And Bind)โโโโโโโโโโโโโโโโฎโโ
โโ โโญโ BindingService โโโฎ โญโ Provisioner โโโโโโฎโโโ
โโ โโ Request Binding โ โ Request Provision โโโโโโโโโโโโโโฎ
โโ โโฐโโโโโโโโโโฌโโโโโโโโโโฏ โฐโโโโโโโโโโโโโโโโโโโโฏโโ (Provisioning)
โโ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโโ Create Exchange, Queue
โโฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โผ โ
โญโ Binder (Lifecycle Start) โโโฎ โผ
โโญโ AMQP Listener Container โโฎโ โญโโโโโ RabbitMQ โโโโโโโโโโโโโโโฎ
โโ โญโโโโโโโโโโโโโโโโโโโโโโฎ โโ โ โญโโโโโโโโโโฎ โโโโโโโโโโโโโโโ
โโ โ Consumer Instance 1 โโโโโโ Binding! โโโถโ Queue 1 โ โ โ โ Exchange 1 โโ
โโ โฐโโโโโโโโโโโโโโโโโโโโโโฏ โโ โ โฐโโโโโโโโโโฏ โโโโโโโโโโโโโโโ
โโ โญโโโโโโโโโโโโโโโโโโโโโโฎ โโ โ โญโโโโโโโโโโฎ โโโโโโโโโโโโโโโ
โโ โ Consumer Instance 2 โโโโโโ Binding! โโโถโ Queue 1 โ โ โ โ Exchange 1 โโ
โโ โฐโโโโโโโโโโโโโโโโโโโโโโฏ โโ โ โฐโโโโโโโโโโฏ โโโโโโโโโโโโโโโ
โโ โญโโโโโโโโโโโโโโโโโโโโโโฎ โโ โ โญโโโโโโโโโโฎ โโโโโโโโโโโโโโโ
โโ โ Consumer Instance 3 โโโโโโ Binding! โโโถโ Queue 1 โ โ โ โ Exchange 1 โโ
โโ โฐโโโโโโโโโโโโโโโโโโโโโโฏ โโ โ โฐโโโโโโโโโโฏ โโโโโโโโโโโโโโโ
โโฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
RabbitMessageChannelBinder
Exchange์ Queue ๋ด๋ถ์ ์ผ๋ก ์ค์ ์ ๊ธฐ๋ฐ์ผ๋ก ํ๋ก๋น์ ๋ํ๊ณ , ๊ตฌ์ฑ๋ ํจ์์ ๋ฐ์ธ๋ฉํ๋ค. AMQP Listener Conainer์์๋ ๋ด๋ถ์ ์ผ๋ก Consumer Instance (AsyncMessageProcessingConsumer)๋ฅผ ํตํด RabbitMQ์ ํต์ ํ๋ค. ๋ฉ์ธ์ง ์์ ์ปดํฌ๋ํธ(SimpleMessageListenerContainer)๋ ๋ฉ์ธ์ง๋ฅผ ๋น๋๊ธฐ์ ์ผ๋ก ์์ ํ๊ฒ ์์ ํ๊ธฐ ์ํด ์ฌ์ฉ๋๋ ํต์ฌ ์ปดํฌ๋ํธ์ด๋ค.
๋ด๋ถ์ ์ผ๋ก BlockingQueueConsumer๋ฅผ ํตํด TransactionTemplate์ ์ฌ์ฉํ์ฌ ๋ฉ์์ง ์์ ์ ์์์ฑ์ ๋ณด์ฅํ๋ฉฐ, ๋์์ฑ ์ ์ด๋ ๊ฐ๋ฅํ๋ค. ์ปจ์๋จธ ์ธ์คํด์ค๋ ๋ฐ์ธ๋ฉ์ด ๋ ์ดํ๋ถํฐ ๋ฉ์์ง ๊ด๋ฆฌ๋ฅผ ์์ํ๋ค.
