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



3000번 포트를 개방할 경우..


sudo firewall-cmd --permanent --zone=public --add-port=3000/tcp

sudo firewall-cmd --reload




altibase@MyUbuntu:~$  df -P -k /home | grep -v File

/dev/sda1         29799484 20586024   7676692      73% /

altibase@MyUbuntu:~$ df -P -k /home | grep -v File | sed  -e "s/\ \+/ /g"  

/dev/sda1 29799484 20586040 7676676 73% /



df -k  디렉토리PATH


altibase@MyUbuntu:~$ df -k /home/altibase

Filesystem     1K-blocks     Used Available Use% Mounted on

/dev/sda1       29799484 20630128   7632588  73% /

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

[centos] port 외부로 여는 명령어  (0) 2018.07.24
파일 검색방법 참고  (0) 2018.07.17
포트 스캔하는 명령  (0) 2018.07.14
od - 바이너리 파일 덤프  (0) 2018.07.01
vim을 shell script에서 실행하는 방법  (0) 2018.04.27


파일 검색 관련 유용한 설명 


http://greenfishblog.tistory.com/54

NC 명령을 사용해서  포트 스캔을 할 수 있다.


omegaman@MyUbuntu:~$ nc -zv 127.0.0.1 8085-8088

nc: connect to 127.0.0.1 port 8085 (tcp) failed: Connection refused

Connection to 127.0.0.1 8086 port [tcp/*] succeeded!

nc: connect to 127.0.0.1 port 8087 (tcp) failed: Connection refused

Connection to 127.0.0.1 8088 port [tcp/omniorb] succeeded!

omegaman@MyUbuntu:~$  nc -zv 127.0.0.1 8086

Connection to 127.0.0.1 8086 port [tcp/*] succeeded!

8진수 덤프

od ( Octal dump)  바이너리 파일을 8진수로 덤프한다.


사용예


omegaman@MyUbuntu:~$ od /usr/bin/file | head -5

0000000 042577 043114 000402 000001 000000 000000 000000 000000

0000020 000002 000076 000001 000000 016740 000100 000000 000000

0000040 000100 000000 000000 000000 041520 000000 000000 000000

0000060 000000 000000 000100 000070 000011 000100 000035 000034

0000100 000006 000000 000005 000000 000100 000000 000000 000000


omegaman@MyUbuntu:~$ od -t a  /usr/bin/file | head -5

0000000 del   E   L   F stx soh soh nul nul nul nul nul nul nul nul nul

0000020 stx nul   > nul soh nul nul nul   `  gs   @ nul nul nul nul nul

0000040   @ nul nul nul nul nul nul nul   P   C nul nul nul nul nul nul

0000060 nul nul nul nul   @ nul   8 nul  ht nul   @ nul  gs nul  fs nul

0000100 ack nul nul nul enq nul nul nul   @ nul nul nul nul nul nul nul


omegaman@MyUbuntu:~$ od -t c /usr/bin/file | head -5

0000000 177   E   L   F 002 001 001  \0  \0  \0  \0  \0  \0  \0  \0  \0

0000020 002  \0   >  \0 001  \0  \0  \0 340 035   @  \0  \0  \0  \0  \0

0000040   @  \0  \0  \0  \0  \0  \0  \0   P   C  \0  \0  \0  \0  \0  \0

0000060  \0  \0  \0  \0   @  \0   8  \0  \t  \0   @  \0 035  \0 034  \0

0000100 006  \0  \0  \0 005  \0  \0  \0   @  \0  \0  \0  \0  \0  \0  \0


omegaman@MyUbuntu:~$ od -t x1z -A x /usr/bin/file | head -5

000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00  >.ELF............<

000010 02 00 3e 00 01 00 00 00 e0 1d 40 00 00 00 00 00  >..>.......@.....<

000020 40 00 00 00 00 00 00 00 50 43 00 00 00 00 00 00  >@.......PC......<

000030 00 00 00 00 40 00 38 00 09 00 40 00 1d 00 1c 00  >....@.8...@.....<

000040 06 00 00 00 05 00 00 00 40 00 00 00 00 00 00 00  >........@.......<


omegaman@MyUbuntu:~$ od -t x1c -A x /usr/bin/file | head -5

000000  7f  45  4c  46  02  01  01  00  00  00  00  00  00  00  00  00

       177   E   L   F 002 001 001  \0  \0  \0  \0  \0  \0  \0  \0  \0

000010  02  00  3e  00  01  00  00  00  e0  1d  40  00  00  00  00  00

       002  \0   >  \0 001  \0  \0  \0 340 035   @  \0  \0  \0  \0  \0

000020  40  00  00  00  00  00  00  00  50  43  00  00  00  00  00  00







Avoiding global variables means you can use the function in a pipe. Here is an example:

#!/bin/bash

makeJunk()
{
   echo 'this is junk'
   echo '#more junk and "b@d" characters!'
   echo '!#$^%^&(*)_^&% ^$#@:"<>?/.,\\"'"'"
}

processJunk()
{
    local -a arr=()    
    # read each input and add it to arr
    while read -r line
    do 
       arr[${#arr[@]}]='"'"$line"'" is junk'; 
    done;

    # output the array as a string in the "declare" representation
    declare -p arr | sed -e 's/^declare -a [^=]*=//'
}

# processJunk returns the array in a flattened string ready for "declare"
# Note that because of the pipe processJunk cannot return anything using
# a global variable
returned_string=`makeJunk | processJunk`

# convert the returned string to an array named returned_array
# declare correctly manages spaces and bad characters
eval "declare -a returned_array=${returned_string}"

for junk in "${returned_array[@]}"
do
   echo "$junk"
done

Output is:

"this is junk" is junk
"#more junk and "b@d" characters!" is junk
"!#$^%^&(*)_^&% ^$#@:"<>?/.,\\"'" is junk




/* runLoader.sh */


wait4loader()

{

while(true)

do

     CNT=`ps -ef | grep -v grep | grep -c loader`

    if [ $CNT -ge 16 ]; then     #  이미 지정된 갯수보다 더 많은  프로세스가 동시 실행중이면

          sleep 1;                    #   대기한다.   16= CPU core 수

    else

          break;                     # 적으면 다음 프로세스 추가 실횅을 위해서 loop를 빠져 나간다.

   fi


done


}



loaderTable(0

{

     if [ $TABLE != "X" ] ; then

         loader ... -T $TABLE

     fi


}


for  TABLE in ${TABLES[@]}

do

           TABLE=${TABLE:="X"}

           wait4loader

           loaderTable


done


+ Recent posts