📜 ⬆️ ⬇️

Asterisk queues, minor tricks

I want to tell you about some tricks with queues in asterisk to which I came to solve problems with callback. Please keep in mind that I am a novice specialist and the tricks that I “discovered” have long been solved in one way or another. Nevertheless, it is likely that this information will also be useful to someone.

The main condition was to use only standard functionality without accessing external scripts.

Queue from local channels


In the initial task there were several stupid gateways (without their own queues) with two or more channels in each, through which it was necessary to call back with varying degrees of uniformity.

queues.conf
[queue-out] strategy=rrmemory autofill=yes ringinuse=no ;              member => Local/out11@dialout member => Local/out12@dialout member => Local/out21@dialout member => Local/out22@dialout 

extensions.conf
 exten => _X.,1,NoOp() same => n,Set(_NEXTEN=${EXTEN}) ;     same => n,Queue(queue-out,r) same => n,Hangup [dialout] exten => out11,1,Dial(SIP/gate1/01${NEXTEN}) ;         same => n,Hangup exten => out12,1,Dial(SIP/gate1/02${NEXTEN}) same => n,Hangup exten => out21,1,Dial(SIP/gate2/01${NEXTEN}) same => n,Hangup exten => out22,1,Dial(SIP/gate2/02${NEXTEN}) same => n,Hangup 

Queue of local channels - option 2 and load control


Peers with an unlimited number of channels were added, it was necessary to describe them for the queue. Along the way, it turned out that in this way you can control the number of outgoing calls - how many channels we will write, so many calls will be made at the same time.
')
queues.conf
 [queue-out] strategy=rrmemory autofill=yes ringinuse=no ;   14   ;    -   ,      ;   14   member => Local/out01@dialout member => Local/out02@dialout member => Local/out03@dialout member => Local/out04@dialout ... member => Local/out12@dialout member => Local/out13@dialout member => Local/out14@dialout 

extensions.conf
 exten => _X.,1,NoOp() same => n,Set(_NEXTEN=${EXTEN}) ;     same => n,Queue(queue-out,r) same => n,Hangup [dialout] exten => _outXX,1,Dial(SIP/provider1/${NEXTEN}) ;     same => n,Hangup 

Queue of local channels - option 3 and reservation


We have two feasts - the main and the spare. Accordingly, we are calling to the first one until we reach the limits we have established, and if we exceed, we gradually switch to a spare one. Or the first for some reason becomes unavailable - then immediately go to the spare.

queues.conf
 [queue-out] strategy=linear ;     ; -  ,     ,      - autofill=yes ringinuse=no ; 30 , 20  -   ,  ,    member => Local/prov1out01@dialout member => Local/prov1out02@dialout member => Local/prov1out03@dialout --- member => Local/prov1out29@dialout member => Local/prov1out30@dialout member => Local/prov2out01@dialout member => Local/prov2out02@dialout member => Local/prov2out03@dialout --- member => Local/prov2out19@dialout member => Local/prov2out20@dialout 

extensions.conf
 exten => _X.,1,NoOp() same => n,Set(_NEXTEN=${EXTEN}) ;     same => n,Queue(queue-out,r) same => n,Hangup [dialout] exten => _prov1outXX,1,Dial(SIP/provider1/${NEXTEN}) same => n,Hangup exten => _prov2outXX,1,Dial(SIP/provider2/${NEXTEN}) same => n,Hangup 

Problems


Do not forget to restart asterisk ( service asterisk restart or core restart now from the console) after changing the queue parameters - module reload or queue reload all not enough - the changes will be shown but will not be used (Invalid status in the list of participants).

With the linear strategy, the queue participants became inactive after a short time (the channel seemed to fall asleep). I did not find out what the problem was, I decided with a crutch in the form of creating a dynamic queue and periodically re-creating the participants. Maybe someone came across and decided? Unsubscribe in the comments.

Total


In principle, if there is a need as well as fantasy / ingenuity, you can make interesting constructions - control of incoming / outgoing load, redundancy (double or more), various options for channel search, and combinations of the above. I hope someone will come in handy.

Source: https://habr.com/ru/post/324580/


All Articles