Asterisk Advanced Message Queue Protocol

Install Erlang

wget -O - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc" |  apt-key add -
 
apt-get update
 
apt-get install erlang-nox
/etc/apt/sources.list.d/bintray.erlang.list
deb https://dl.bintray.com/rabbitmq/debian jessie erlang

Install Rabbitmq

echo "deb https://dl.bintray.com/rabbitmq/debian jessie  main" |  tee /etc/apt/sources.list.d/bintray.rabbitmq.list
 
wget -O - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc" |  apt-key add -
 
apt-get update
 
apt-get install rabbitmq-server
/etc/apt/sources.list.d/bintray.rabbitmq.list
deb https://dl.bintray.com/rabbitmq/debian jessie  main

HTTP Api Enable

 rabbitmq-plugins enable rabbitmq_management

Test HTTP Api

 curl -i -u guest:guest http://localhost:15672/api/vhosts

Нажмите, чтобы отобразить

Нажмите, чтобы скрыть

HTTP/1.1 200 OK
cache-control: no-cache
content-length: 849
content-security-policy: default-src 'self'
content-type: application/json
date: Mon, 28 Jan 2019 08:36:07 GMT
server: Cowboy
vary: accept, accept-encoding, origin
 
 
[{"cluster_state":{"rabbit@asterisk-pbx.ru":"running"},"message_stats":{"ack":0,"ack_details":{"rate":0.0},"confirm":11,"confirm_details":{"rate":0.0},"deliver":0,"deliver_details":{"rate":0.0},"deliver_get":808,"deliver_get_details":{"rate":0.0},"deliver_no_ack":0,"deliver_no_ack_details":{"rate":0.0},"get":808,"get_details":{"rate":0.0},"get_no_ack":0,"get_no_ack_details":{"rate":0.0},"publish":120556,"publish_details":{"rate":0.6},"redeliver":363,"redeliver_details":{"rate":0.0},"return_unroutable":5,"return_unroutable_details":{"rate":0.0}},"messages":72,"messages_details":{"rate":0.0},"messages_ready":72,"messages_ready_details":{"rate":0.0},"messages_unacknowledged":0,"messages_unacknowledged_details":{"rate":0.0},"name":"/","recv_oct":53905599,"recv_oct_details":{"rate":224.0},"send_oct":161709,"send_oct_details":{"rate":1.6},"tracing":false}]

Web UI

Create User
rabbitmqctl add_user admin password 
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
Open port 15672

res_amqp.so

apt-get install librabbitmq-dev
git clone https://github.com/wazo-pbx/wazo-res-amqp.git
cd /usr/src/wazo-res-amqp/
make
make install
make samples
cp /usr/src/wazo-res-amqp/documentation/res_amqp_config-en_US.xml  /var/lib/asterisk/documentation/thirdparty/

res_stasis_amqp.so

git clone https://github.com/wazo-pbx/wazo-res-stasis-amqp.git
cp -r /usr/src/wazo-res-amqp/asterisk /usr/src/wazo-res-stasis-amqp/
cd /usr/src/wazo-res-stasis-amqp/
make
make install
make samples
cp /usr/src/wazo-res-stasis-amqp/documentation/res_stasis_amqp_config-en_US.xml  /var/lib/asterisk/documentation/thirdparty/

/etc/asterisk/amqp.conf

[general]
enabled = yes  ; Set to no to disable
 
[bunny]
type = connection
url = amqp://localhost         ; amqp://[$USERNAME@]$HOST[:$PORT][/$VHOST]
                                ;  username defaults to guest
                                ;  port defaults to 5672
                                ;  vhost defaults to /
;password =                     ; Password to use for login
                                ;  defaults to guest
;max_frame_bytes =              ; Maximum frame size, in bytes; defaults to
                                ; AMQP_DEFAULT_FRAME_SIZE (131072, or 128KB)
;heartbeat_seconds =            ; number of seconds between heartbeat frames
                                ; 0 disables hearbeats; defaults to
                                ; AMQP_DEFAULT_HEARTBEAT (0)

/etc/asterisk/stasis_amqp.conf

[global]
connection = bunny      ; Connection name in amqp.conf
;queue =  ; Queue name to publish to; defaults to asterisk_cdr
exchange = amq.topic             ; Exchange to publish to; defaults to empty string

asterisk

Check res_stasis & app_stasis

*CLI> module show like stasis
Module                         Description                              Use Count  Status      Support Level
app_stasis.so                  Stasis dialplan application              0          Running              core
res_stasis.so                  Stasis application support               1          Running              core

Load res_amqp.so

*CLI> module load res_amqp.so
Loaded res_amqp.so
 Loaded res_amqp.so => (AMQP Interface)

Load res_stasis_amqp.so (requires an existing connection with rabbitmq )

*CLI> module load res_stasis_amqp.so
Loaded res_stasis_amqp.so
  == Parsing '/etc/asterisk/stasis_amqp.conf': Found
 Loaded res_stasis_amqp.so => (Send all Stasis messages to AMQP)
*CLI> module show like amqp
Module                         Description                              Use Count  Status      Support Level
res_amqp.so                    AMQP Interface                           0          Running              core
res_stasis_amqp.so             Send all Stasis messages to AMQP         0          Running          extended
2 modules loaded

Asterisk Stasis Channel Event

Asterisk Stasis Channel Even

Asterisk Stasis Channel Even

Message 18
The server reported 139 messages remaining.
 
Exchange	amq.topic
Routing Key	stasis.channel.1548662902.15
Redelivered	○
Properties	
delivery_mode:	2
content_type:	application/json
Payload
469 bytes
Encoding: string
{"event":"stasis_channel","eid":"78:32:1b:f6:22:f5","data":{"type":"ChannelVarset","variable":"STASISSTATUS","value":"","timestamp":"2019-01-28T11:08:22.879+0300","channel":{"id":"1548662902.15","language":"en","name":"PJSIP/fs_pjsip-00000005","connected":{"name":"","number":""},"state":"Up","caller":{"name":"O.Smirnov","number":"2666"},"accountcode":"","dialplan":{"context":"from-test2","exten":"72668","priority":2},"creationtime":"2019-01-28T11:08:22.759+0300"}}}

Asterisk Stasis AMI Event

  1. Enter queue: QueueCallerJoin
  2. Agent ringigng: AgentCalled
  3. Agent no answer for timeout: AgentRingNoAnswer
  4. Caller Leave Queue: QueueCallerAbandon, QueueCallerLeave

Stasis AMI Event

Stasis AMI Event

Message 1
The server reported 4 messages remaining.
 
Exchange	amq.topic
Routing Key	stasis.ami.queuecallerjoin
Redelivered	●
Properties	
delivery_mode:	2
content_type:	application/json
Payload
463 bytes
Encoding: string
{"event":"QueueCallerJoin","eid":"78:32:1b:f6:22:f5","data":{"Event":"QueueCallerJoin","AccountCode":"","Context":"from-test2","Channel":"PJSIP/fs_pjsip-0000001a","ChannelState":"6","Language":"en","ConnectedLineNum":"<unknown>","Exten":"72668","CallerIDNum":"2666","Uniqueid":"1548672880.81","Linkedid":"1548672880.81","ChannelStateDesc":"Up","Queue":"q_test","CallerIDName":"O.Smirnov","Count":"1","ConnectedLineName":"<unknown>","Priority":"3","Position":"1"}}
Message 2
The server reported 3 messages remaining.
 
Exchange	amq.topic
Routing Key	stasis.ami.agentcalled
Redelivered	●
Properties	
delivery_mode:	2
content_type:	application/json
Payload
860 bytes
Encoding: string
{"event":"AgentCalled","eid":"78:32:1b:f6:22:f5","data":{"Event":"AgentCalled","AccountCode":"","Context":"from-test2","Channel":"PJSIP/fs_pjsip-0000001a","ChannelState":"6","Language":"en","ConnectedLineNum":"<unknown>","Exten":"72668","CallerIDNum":"2666","Uniqueid":"1548672880.81","Linkedid":"1548672880.81","ChannelStateDesc":"Up","Queue":"q_test","CallerIDName":"O.Smirnov","DestExten":"72668","DestAccountCode":"","ConnectedLineName":"<unknown>","Interface":"SIP/72666","DestLanguage":"ru","DestConnectedLineNum":"2666","Priority":"3","DestPriority":"1","DestChannel":"SIP/72666-0000001a","DestCallerIDNum":"72666","DestChannelState":"0","DestChannelStateDesc":"Down","DestCallerIDName":"O.Smirnov","DestConnectedLineName":"O.Smirnov","DestContext":"mobile-asterisk-spb","MemberName":"666","DestLinkedid":"1548672880.81","DestUniqueid":"1548672881.82"}}
Message 3
The server reported 2 messages remaining.
 
Exchange	amq.topic
Routing Key	stasis.ami.agentringnoanswer
Redelivered	●
Properties	
delivery_mode:	2
content_type:	application/json
Payload
894 bytes
Encoding: string
{"event":"AgentRingNoAnswer","eid":"78:32:1b:f6:22:f5","data":{"Context":"from-test2","Event":"AgentRingNoAnswer","AccountCode":"","Channel":"PJSIP/fs_pjsip-0000001a","ChannelState":"6","Language":"en","ConnectedLineNum":"<unknown>","Exten":"72668","Linkedid":"1548672880.81","Uniqueid":"1548672880.81","CallerIDNum":"2666","ChannelStateDesc":"Up","Queue":"q_test","CallerIDName":"O.Smirnov","DestExten":"72668","ConnectedLineName":"<unknown>","DestAccountCode":"","DestLanguage":"ru","Interface":"SIP/72666","Priority":"3","DestConnectedLineNum":"2666","DestChannel":"SIP/72666-0000001a","DestPriority":"1","DestCallerIDNum":"72666","DestChannelState":"5","DestChannelStateDesc":"Ringing","DestCallerIDName":"O.Smirnov","DestConnectedLineName":"O.Smirnov","DestContext":"mobile-asterisk-spb","DestLinkedid":"1548672880.81","MemberName":"666","DestUniqueid":"1548672881.82","RingTime":"15000"}}
Message 4
The server reported 1 messages remaining.
 
Exchange	amq.topic
Routing Key	stasis.ami.queuecallerabandon
Redelivered	●
Properties	
delivery_mode:	2
content_type:	application/json
Payload
496 bytes
Encoding: string
{"event":"QueueCallerAbandon","eid":"78:32:1b:f6:22:f5","data":{"Event":"QueueCallerAbandon","AccountCode":"","Context":"from-test2","Channel":"PJSIP/fs_pjsip-0000001a","ChannelState":"6","Language":"en","ConnectedLineNum":"<unknown>","Exten":"72668","CallerIDNum":"2666","Uniqueid":"1548672880.81","Linkedid":"1548672880.81","ChannelStateDesc":"Up","CallerIDName":"O.Smirnov","Queue":"q_test","OriginalPosition":"1","ConnectedLineName":"<unknown>","Priority":"3","Position":"1","HoldTime":"18"}}
Message 5
The server reported 0 messages remaining.
 
Exchange	amq.topic
Routing Key	stasis.ami.queuecallerleave
Redelivered	●
Properties	
delivery_mode:	2
content_type:	application/json
Payload
465 bytes
Encoding: string
{"event":"QueueCallerLeave","eid":"78:32:1b:f6:22:f5","data":{"Event":"QueueCallerLeave","AccountCode":"","Context":"from-test2","Channel":"PJSIP/fs_pjsip-0000001a","ChannelState":"6","Language":"en","ConnectedLineNum":"<unknown>","Exten":"72668","CallerIDNum":"2666","Uniqueid":"1548672880.81","Linkedid":"1548672880.81","ChannelStateDesc":"Up","Queue":"q_test","CallerIDName":"O.Smirnov","Count":"0","ConnectedLineName":"<unknown>","Priority":"3","Position":"1"}}

asterisk

rabbitmq

<< Новые записи | Предыдущие записи >>

Только авторизованные участники могут оставлять комментарии.
  • blog.txt
  • Последние изменения: 2018/07/04