Rabbitmq 공통모듈 작성을 위한 기본 소스 작성및  기능분석

1.  c library  api 문서

http://alanxz.github.io/rabbitmq-c/docs/0.8.0/amqp_8h.html

http://alanxz.github.io/rabbitmq-c/docs/0.2/amqp_8h.html

https://blog.naver.com/tireeo/220303953568

2. 큐 유형별 예제

2.1  fair dispatch 형 ( Work Queue 형 )

https://blog.naver.com/tireeo/220303948203

 * 큐에 있는 내용을 하나씩 교대로 꺼내감.  꺼내갈때는 한번에 하나씩 꺼내가는 것처럼 보이지만 실제로는 prefetch 해 간다. 따라서  consumer가 죽으면 큐대기열에서 안꺼내간 큐가 남을 수 있다.

*  이 문제를 해결하기 위해서는 channel.basicQos(1) 사용 필요 , 사용법 확인 필요함.

2.1.1  sample 소스 

mytest-dispatch\   에  위  유형 예제 있음.

 2.1.2 실행방법

  #터미널1   sh  recv.sh

  # 터미널2  sh recv.sh

  # 터미널3  sh send.sh


2.2 Publish / subcribe ( fanout )

* 큐대기열에 같은 내용을 복제한다.  consumer1 과 consumer2 가 같은 내용의 큐를 가져간다.

2.2.1 sample 소스

mytest-prosub-fanout\ 에   예제 소스 


2.2.1 실행방법

  #터미널1   sh  recv.sh

  # 터미널2  sh recv.sh

  # 터미널3  sh send.sh

2.3 Routing

   

* routing key 값에 따라서  exchange가 분배해주는 큐의 위치가 달라진다.   같은 routing key 값을 사용하면  같은 내용이 복제되는 fanout과 같은 방식이 된다.

2.3.1   sample 소스

mytest-routing\

2.3.2 실행방법

#터미널1    sh send.sh

# 터미널2   sh send2.sh

# 터미널3   sh  recv.sh

# 터미널4   sh  recv2.sh

2.4 Topic 방식 ( 사용 안할 예정)

* routing key 값의 패턴에 따라서  exchange --> queue  방향이 정해진다. 예들 들어서   routing key가  *.black.* 로  exchange 에 바인딩 큐대기열은  routing key 가  abc.black.twotwo 인 메시지가 저장되는 큐가 된다.

2.4.1  sample 소스

mytest-topic\

2.4.2 실행방법

#터미널1    sh  send.sh

#터미널2    sh  recv.sh

#터미널3    sh  send2.sh

#터미널4    sh  recv2.sh

'시스템 > RabbitMQ' 카테고리의 다른 글

rabbitMQ 종류  (0) 2018.09.09


설명 잘되어 있는 곳 : http://blog.naver.com/tireeo/220303953568



sample 소스 :  https://github.com/hoxnox/examples.amqp-cpp


sample 소스 2: https://www.rabbitmq.com/devtools.html


위소스에 대한 설명있는 URL : http://alanxz.github.io/rabbitmq-c/docs/0.8.0/

'시스템 > RabbitMQ' 카테고리의 다른 글

rabbitMQ sample 소스  (0) 2018.09.30

+ Recent posts