Posts Network-AMQP
Post
Cancel

Network-AMQP

Network-AMQP


๐Ÿ’ฟ AMQP ํ†ต์‹ 

Advanced Message Queing Protocal์˜ ์•ฝ์ž๋กœ ํ”ํžˆ ์•Œ๊ณ ์žˆ์€ MQ์˜ ์˜คํ”ˆ์†Œ์Šค์— ๊ธฐ๋ฐ˜ํ•œ ํ‘œ์ค€ ํ”„๋กœํ† ์ฝœ

  • ๊ฐ€์žฅ ๋งŽ์ด ์“ฐ๋Š” ๊ฑด erlang๊ณผ ์ž๋ฐ”์— ๊ธฐ๋ฐ˜์„ ๋‘” RabbitMQ ___

๐Ÿ’ฟ ๋“ฑ์žฅ ๋ฐฐ๊ฒฝ

  • ์ƒ์šฉํ™”๋œ MQ ์ œํ’ˆ๋“ค
    • ๋Œ€๋ถ€๋ถ„ ํ”Œ๋žซํผ ์ข…์†์ : ์„œ๋กœ ๋‹ค๋ฅธ ์„œ๋น„์Šค ๊ฐ„์— ๋ฉ”์‹œ์ง€๋ฅผ ๊ตํ™˜ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋ฉ”์„ธ์ง€ ํฌ๋ฉง ์ปจ๋ฒ„์ „์„ ํ†ตํ•œ ๋ฉ”์‹œ์ง€ ๋ธŒ๋ฆฟ์ง€๋ฅผ ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜ ์‹œ์Šคํ…œ ์ž์ฒด๋ฅผ ํ†ตํ•ฉํ•  ํ•„์š”๊ฐ€ ์žˆ์—ˆ์Œ
    • MQ๋Š” ๊ธˆ์œต ์ชฝ์—์„œ ๋งŽ์ด ์‚ฌ์šฉ๋จ
    • ์ด๋Ÿฌํ•œ ์•ฝ์ ์„ ์‚ฌ์šฉ ๋ณด์™„ํ•˜๋Š” ๊ฒƒ์ด AMQP
  • ์„œ๋กœ ๋‹ค๋ฅธ ์‹œ์Šคํ…œ ๊ฐ„์— ์ตœ๋Œ€ํ•œ ํšจ์œจ์ ์œผ๋กœ ๋ฉ”์‹œ์ง€๋ฅผ ๊ตํ™˜ํ•˜๊ธฐ ์œ„ํ•œ MQ ํ”„๋กœํ† ์ฝœ
  • ๋ฒค๋”์— ์ข…์†๋˜๋Š” ๊ฒƒ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด ์•„๋ž˜์™€ ๊ฐ™์€ ์กฐ๊ฑด์„ ์ถฉ์กฑ
    • ๋ชจ๋“  broker, client๋“ค์€ ๋˜‘๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ๋™์ž‘ํ•  ๊ฒƒ
    • ๋„คํŠธ์›์ƒ์œผ๋กœ ์ „์†ก๋˜๋Š” ๋ช…๋ น์–ด๋“ค์˜ ํ‘œ์ค€ํ™”
    • ํ”„๋กœ๊ทธ๋žจ ์–ธ์–ด ์ค‘๋ฆฝ์  ___

๐Ÿ’ฟ AMQP Routing model

image

Exchange

publisher๋กœ ๋ถ€ํ„ฐ ์ˆ˜์‹ ํ•œ ๋ฉ”์‹œ์ง€๋ฅผ ์ ์ ˆํ•œ ํ ๋˜๋Š” ๋‹ค๋ฅธ exchange๋กœ ๋ถ„๋ฐฐํ•˜๋Š” ๋ผ์šฐํ„ฐ ๊ธฐ๋Šฅ์„ ํ•œ๋‹ค.

  • Exchange๋Š” ์ˆ˜์‹ ํ•œ ๋ฉ”์‹œ์ง€๋ฅผ ๋ถ„๋ฐฐํ•˜๊ธฐ์œ„ํ•ด Exchange Type์ด๋ผ๋Š” ๋ผ์šฐํŒ… ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‚ฌ์šฉ
    • ๋ธŒ๋กœ๊ฑฐ๋Š” ์—ฌ๋Ÿฌ๊ฐœ์˜ Exchange Type์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค.
  • Exchange Type์€ ๋ฐ›์€ ๋ฉ”์‹œ์ง€๋ฅผ ์–ด๋–ค ๋ฐฉ๋ฒ•์œผ๋กœ ๋ผ์šฐํŒ…ํ• ์ง€ ๊ฒฐ์ •ํ•˜๋Š”๊ฒƒ
    • Binding์€ ์ด๋Ÿฌํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ๊ฒฐ์ •๋œ ๋ฉ”์‹œ์ง€๋ฅผ ์–ด๋Š Queue์— ์ „๋‹ฌํ• ์ง€ ๊ฒฐ์ •ํ•˜๋Š” Routing Table

Exchange Type

ํƒ€์ž…์„ค๋ช…ํŠน์ง•
DirectRouting key๊ฐ€ ์ •ํ™•ํžˆ ์ผ์น˜ํ•˜๋Š” Queue์— ๋ฉ”์‹œ์ง€ ์ „์†กUnicast
TopicRouting key ํŒจํ„ด์ด ์ผ์น˜ํ•˜๋Š” Queue์— ๋ฉ”์‹œ์ง€ ์ „์†กMulticast
Headers[key:value]๋กœ ์ด๋ฃจ์–ด์ง„ header ๊ฐ’์„ ๊ธฐ์ค€์œผ๋กœ ์ผ์น˜ํ•˜๋Š” queue์— ์ „์†กMulticast
Fanoutํ•ด๋‹น Exchange์— ๋“ฑ๋ก๋œ ๋ชจ๋“  Queue์— ๋ฉ”์„ธ์ง€ ์ „์†กBroadCast

Direct Exchange

image

๋ฉ”์‹œ์ง€์˜ ๋ผ์šฐํŒ… ํ‚ค๋ฅผ ํ์— 1:1์œผ๋กœ ๋งค์นญ์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•

์ผ๋ฐ˜์ ์œผ๋กœ ํ์˜ ์ด๋ฆ„์„ ๋ฐ”์ธ๋”ฉ๊ณ ์ž ํ•˜๋Š” ๋ผ์šฐํŒ… ํ‚ค์™€ ๋™์ผํ•˜๊ฒŒ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ๋‹ค.

Topic Exchange

์™€์ผ๋“œ์นด๋“œ๋ฅผ ์ด์šฉํ•ด์„œ ๋ฉ”์‹œ์ง€๋ฅผ ํ์— ๋งค์นญ์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•

image

๋ฉ”์‹œ์ง€์˜ ๋ผ์šฐํŒ… ํ‚ค๋ฅผ ํ์— 1:N์œผ๋กœ ๋งค์นญ์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•

Headers Exchange

image

key-valie๋กœ ์ •์˜๋œ ํ—ค๋”์— ์˜ํ•ด ๋ผ์šฐํŒ…์„ ๊ฒฐ์ •ํ•œ๋‹ค.

x-match๋ผ๋Š” ํŠน๋ณ„ํ•œ argument๋กœ ํ—ค๋”๋ฅผ ์–ด๋–ค์‹์œผ๋กœ ํ•ด์„ํ•˜๊ณ  ๋ฐ”์ธ๋”ฉํ• ์ง€๋ฅผ ๊ฒฐ์ •ํ•˜๋Š”๋ฐ,

  • x-match๊ฐ€ all์ด๋ฉด ๋ฐ”์ธ๋”ฉ ์กฐ๊ฑด์„ ๋ชจ๋‘ ์ถฉ์กฑ์‹œ์ผœ์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์ด๊ณ (AND),
  • any์ด๋ฉด ํ•˜๋‚˜๋งŒ ์ถฉ์กฑ์‹œํ‚ค๋ฉด ๋œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.

Fanout Exchange

image

๋ชจ๋“  ๋ฉ”์„ธ์ง€๋ฅผ ๋ชจ๋“  ํ๋กœ ๋ผ์šฐํŒ…ํ•˜๋Š” ์œ ํ˜•์ด๋‹ค.

Queue

๋ฉ”๋ชจ๋ฆฌ๋‚˜ ๋””์Šคํฌ์— ๋ฉ”์‹œ์ง€๋ฅผ ์ €์žฅํ•˜๊ณ  ๊ทธ๊ฒƒ์„ Consumer์—๊ฒŒ ์ „๋‹ฌํ•˜๋Š” ์—ญํ• 

  • ํ๋Š” ์Šค์Šค๋กœ๊ฐ€ ๊ด€์‹ฌ์žˆ๋Š” ๋ฉ”์‹œ์ง€ ํƒ€์ž…์„ ์ง€์ •ํ•œ Binding์„ ํ†ตํ•ด exchange์— ๋ง๊ทธ๋Œ€๋กœ binding ๋œ๋‹ค.

Binding

exchange์™€ Queue์™€์˜ ๊ด€๊ณ„๋ฅผ ์ •์˜ํ•œ ์ผ์ข…์˜ ๋ผ์šฐํŒ… ํ…Œ์ด๋ธ”

  • ๊ฐ™์€ ํ๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ์˜ exchange์— bind ๋  ์ˆ˜๋„ ์žˆ๊ณ , ํ•˜๋‚˜์˜ exchange์— ์—ฌ๋Ÿฌ๊ฐœ์˜ ํ๊ฐ€ binding ๋  ์ˆ˜๋„ ์žˆ๋‹ค.

Routing Key

Publisher์—์„œ ์†ก์‹ ํ•œ ๋ฉ”์‹œ์ง€ ํ—ค๋”์— ํฌํ•จ๋˜๋Š” ๊ฒƒ์œผ๋กœ ์ผ์ข…์˜ ๊ฐ€์ƒ ์ฃผ์†Œ

  • Exchange๋Š” ์ด๊ฒƒ์„ ์ด์šฉํ•ด์„œ ์–ด๋–ค ํ๋กœ ๋ฉ”์‹œ์ง€๋ฅผ ๋ผ์šฐํŒ…ํ• ๊ฑด์ง€ ๊ฒฐ์ •ํ•  ์ˆ˜ ๋„ ์žˆ๋‹ค.
This post is licensed under CC BY 4.0 by the author.

authentication-jwt

SIY Spring Cloud Api GateWay 1