Realtime Call Queues : Call Members In Certain Order

Home » Asterisk Users » Realtime Call Queues : Call Members In Certain Order
Asterisk Users 5 Comments

Hello,

I’m using MySQL realtime Call Queues (table /queues/ and table
/queue_members/).

I would like to ring the members of the call queue in a certain order. Therefore I use ring strategy /lineair /and I put the members into the table /queue_members/ in the order in which they have to be rang.

So I have the queue :

| name | musicclass | announce | context | timeout |
monitor_type | monitor_format | queue_youarenext | queue_thereare |
queue_callswaiting | queue_holdtime | queue_minutes | queue_seconds |
queue_lessthan | queue_thankyou | queue_reporthold | announce_frequency
| announce_round_seconds | announce_holdtime | announce_position | retry
| wrapuptime | maxlen | servicelevel | strategy | joinempty |
leavewhenempty | eventmemberstatus | eventwhencalled | reportholdtime |
memberdelay | weight | timeoutrestart | periodic_announce |
periodic_announce_frequency | ringinuse |
+—————-+————+———-+———+———+————–+—————-+——————+—————-+——————–+—————-+—————+—————+—————-+—————-+——————+——————–+————————+——————-+——————-+——-+————+——–+————–+———-+———–+—————-+——————-+—————–+—————-+————-+——–+—————-+——————-+—————————–+———–+
| queue6 | default | NULL | | 12 | NULL |
NULL | NULL | NULL | NULL |
NULL | NULL | NULL | NULL |
NULL | NULL | 30 | NULL | No
| yes | 5 | 10 | 0 | NULL |
linear | strict | strict | NULL |
NULL | NULL | NULL | NULL | no
| | 0 | no |
+—————-+————+———-+———+———+————–+—————-+——————+—————-+——————–+—————-+—————+—————+—————-+—————-+——————+——————–+————————+——————-+——————-+——-+————+——–+————–+———-+———–+—————-+——————-+—————–+—————-+————-+——–+—————-+——————-+—————————–+———–+

and queue members :

+———-+—————-+—————-+——————–+———+——–+
| uniqueid | membername | queue_name | interface | penalty |
paused |
+———-+—————-+—————-+——————–+———+——–+
| 44 | queuemem4 | queue6 | SIP/queuemem4 | 0 | NULL |
| 45 | queuemem2 | queue6 | SIP/queuemem2 | 0 | NULL |
| 46 | queuemem5 | queue6 | SIP/queuemem5 | 0 | NULL |
| 47 | queuemem1 | queue6 | SIP/queuemem1 | 0 | NULL |
| 48 | queuemem10 | queue6 | SIP/queuemem10 | 0 | NULL |
| 49 | queuemem18 | queue6 | SIP/queuemem18 | 0 | NULL |
| 50 | queuemem17 | queue6 | SIP/queuemem17 | 0 | NULL |
| 51 | queuemem12 | queue6 | SIP/queuemem12 | 0 | NULL |
| 52 | queuemem16 | queue6 | SIP/queuemem16 | 0 | NULL |
| 53 | queuemem13 | queue6 | SIP/queuemem13 | 0 | NULL |
+———-+—————-+—————-+——————–+———+——–+

You can see that the member /queuemem4/ is first in line to be rang (has the first and lowest uniqueid in the table).

But the first member that is being rang, is /queuemem//1/. How come ??

Kind regards,

Jonas.

5 thoughts on - Realtime Call Queues : Call Members In Certain Order

  • From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens Sent: Wednesday, February 12, 2014 3:46 AM
    To: Asterisk Users Mailing List – Non-Commercial Discussion Subject: [asterisk-users] Realtime Call Queues : call members in certain order

    Hello,

    I’m using MySQL realtime Call Queues (table queues and table queue_members).

    I would like to ring the members of the call queue in a certain order. Therefore I use ring strategy lineair and I put the members into the table queue_members in the order in which they have to be rang.

    So I have the queue :

    | name | musicclass | announce | context | timeout | monitor_type | monitor_format | queue_youarenext | queue_thereare | queue_callswaiting | queue_holdtime | queue_minutes | queue_seconds | queue_lessthan | queue_thankyou | queue_reporthold | announce_frequency | announce_round_seconds | announce_holdtime | announce_position | retry | wrapuptime | maxlen | servicelevel | strategy | joinempty | leavewhenempty | eventmemberstatus | eventwhencalled | reportholdtime | memberdelay | weight | timeoutrestart | periodic_announce | periodic_announce_frequency | ringinuse |
    +—————-+————+———-+———+———+————–+—————-+——————+—————-+——————–+—————-+—————+—————+—————-+—————-+——————+——————–+————————+——————-+——————-+——-+————+——–+————–+———-+———–+—————-+——————-+—————–+—————-+————-+——–+—————-+——————-+—————————–+———–+
    | queue6 | default | NULL | | 12 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 30 | NULL | No | yes | 5 | 10 | 0 | NULL | linear | strict | strict | NULL | NULL | NULL | NULL | NULL | no | | 0 | no |
    +—————-+————+———-+———+———+————–+—————-+——————+—————-+——————–+—————-+—————+—————+—————-+—————-+——————+——————–+————————+——————-+——————-+——-+————+——–+————–+———-+———–+—————-+——————-+—————–+—————-+————-+——–+—————-+——————-+—————————–+———–+

    and queue members :

    +———-+—————-+—————-+——————–+———+——–+
    | uniqueid | membername | queue_name | interface | penalty | paused |
    +———-+—————-+—————-+——————–+———+——–+
    | 44 | queuemem4 | queue6 | SIP/queuemem4 | 0 | NULL |
    | 45 | queuemem2 | queue6 | SIP/queuemem2 | 0 | NULL |
    | 46 | queuemem5 | queue6 | SIP/queuemem5 | 0 | NULL |
    | 47 | queuemem1 | queue6 | SIP/queuemem1 | 0 | NULL |
    | 48 | queuemem10 | queue6 | SIP/queuemem10 | 0 | NULL |
    | 49 | queuemem18 | queue6 | SIP/queuemem18 | 0 | NULL |
    | 50 | queuemem17 | queue6 | SIP/queuemem17 | 0 | NULL |
    | 51 | queuemem12 | queue6 | SIP/queuemem12 | 0 | NULL |
    | 52 | queuemem16 | queue6 | SIP/queuemem16 | 0 | NULL |
    | 53 | queuemem13 | queue6 | SIP/queuemem13 | 0 | NULL |
    +———-+—————-+—————-+——————–+———+——–+

    You can see that the member queuemem4 is first in line to be rang (has the first and lowest uniqueid in the table).

    But the first member that is being rang, is queuemem1. How come ??

    Kind regards,

    Jonas.

    Jonas, We encountered the same problem. It is a bug in the Queue application. The Queue application actually orders members by their interface value. Here is the bug report I opened https://issues.asterisk.org/jira/browse/ASTERISK-18480 which was closed as “Not A Bug” by Digium. We worked around this by prepending an integer (001__, 002__, …) to the interface in the database table and then removing it later in the dial plan. Hope this helps. Steven Wheeler

  • Hello,

    thank you for your reply.

    Is it the “membername” or the “interface” that needs to be sorted to have a certain order in the call queue ?

    How do you remove the prefix (integer) from a call queue member from dialplan ?

    If you call the queue in your dialplan as follow :

    exten => s,n,Queue(${queuename},,,,${timeout})

    How can you “edit” its members ??

    Kind regards,

    Jonas.

  • From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens Sent: Wednesday, February 12, 2014 3:46 AM
    To: Asterisk Users Mailing List – Non-Commercial Discussion Subject: [asterisk-users] Realtime Call Queues : call members in certain order

    Hello,

    I’m using MySQL realtime Call Queues (table queues and table queue_members).

    I would like to ring the members of the call queue in a certain order. Therefore I use ring strategy lineair and I put the members into the table queue_members in the order in which they have to be rang.

    So I have the queue :

    | name | musicclass | announce | context | timeout | monitor_type | monitor_format | queue_youarenext | queue_thereare | queue_callswaiting | queue_holdtime | queue_minutes | queue_seconds | queue_lessthan | queue_thankyou | queue_reporthold | announce_frequency | announce_round_seconds | announce_holdtime | announce_position | retry | wrapuptime | maxlen | servicelevel | strategy | joinempty | leavewhenempty | eventmemberstatus | eventwhencalled | reportholdtime | memberdelay | weight | timeoutrestart | periodic_announce | periodic_announce_frequency | ringinuse |
    +—————-+————+———-+———+———+————–+—————-+——————+—————-+——————–+—————-+—————+—————+—————-+—————-+——————+——————–+————————+——————-+——————-+——-+————+——–+————–+———-+———–+—————-+——————-+—————–+—————-+————-+——–+—————-+——————-+—————————–+———–+
    | queue6 | default | NULL | | 12 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 30 | NULL | No | yes | 5 | 10 | 0 | NULL | linear | strict | strict | NULL | NULL | NULL | NULL | NULL | no | | 0 | no |
    +—————-+————+———-+———+———+————–+—————-+——————+—————-+——————–+—————-+—————+—————+—————-+—————-+——————+——————–+————————+——————-+——————-+——-+————+——–+————–+———-+———–+—————-+——————-+—————–+—————-+————-+——–+—————-+——————-+—————————–+———–+

    and queue members :

    +———-+—————-+—————-+——————–+———+——–+
    | uniqueid | membername | queue_name | interface | penalty | paused |
    +———-+—————-+—————-+——————–+———+——–+
    | 44 | queuemem4 | queue6 | SIP/queuemem4 | 0 | NULL |
    | 45 | queuemem2 | queue6 | SIP/queuemem2 | 0 | NULL |
    | 46 | queuemem5 | queue6 | SIP/queuemem5 | 0 | NULL |
    | 47 | queuemem1 | queue6 | SIP/queuemem1 | 0 | NULL |
    | 48 | queuemem10 | queue6 | SIP/queuemem10 | 0 | NULL |
    | 49 | queuemem18 | queue6 | SIP/queuemem18 | 0 | NULL |
    | 50 | queuemem17 | queue6 | SIP/queuemem17 | 0 | NULL |
    | 51 | queuemem12 | queue6 | SIP/queuemem12 | 0 | NULL |
    | 52 | queuemem16 | queue6 | SIP/queuemem16 | 0 | NULL |
    | 53 | queuemem13 | queue6 | SIP/queuemem13 | 0 | NULL |
    +———-+—————-+—————-+——————–+———+——–+

    You can see that the member queuemem4 is first in line to be rang (has the first and lowest uniqueid in the table).

    But the first member that is being rang, is queuemem1. How come ??

    Kind regards,

    Jonas.

    Jonas, We encountered the same problem. It is a bug in the Queue application. The Queue application actually orders members by their interface value. Here is the bug report I opened https://issues.asterisk.org/jira/browse/ASTERISK-18480 which was closed as “Not A Bug” by Digium. We worked around this by prepending an integer (001__, 002__, …) to the interface in the database table and then removing it later in the dial plan. Hope this helps. Steven Wheeler

    Hello,

    thank you for your reply.

    Is it the “membername” or the “interface” that needs to be sorted to have a certain order in the call queue ?

    How do you remove the prefix (integer) from a call queue member from dialplan ?

    If you call the queue in your dialplan as follow :

    exten => s,n,Queue(${queuename},,,,${timeout})

    How can you “edit” its members ??

    Kind regards,

    Jonas.

    Jonas, When asterisk queries the database for queue members it sorts the results based on the value of the interface column. We use local channels for calling agents (i.e. Local/001__agent@queue_calling/n) so your mileage may vary. To strip off the prefix we have the following in our queue_calling context.
    [queue_calling]
    exten => _XXX__[A-Za-z0-9*#].,1,Goto(${EXTEN:5},1)
    exten => _[A-Za-z0-9*#].,1,…
    … Logic to call the agent’s SIP phone …

  • Hello,

    I have tried this logic with Local channels and a prefix for sorting in the database, but this creates another problem :

    Seemingly my Call Queue is empty, because I get a QUEUESTATUS = JOINEMPTY

    This is now my data in my table :

    +———-+————-+————–+——————————————–+———+——–+
    | uniqueid | membername | queue_name |
    interface | penalty | paused |
    +———-+————-+————–+——————————————–+———+——–+
    | 2381 | 3232323232 | voipq4 |
    Local/01_3232323232@ExternalCallFromQueue | 0 | NULL |
    | 2382 | voip1 | voipq4 |
    Local/02_voip1@ExternalCallFromQueue | 0 | NULL |
    | 2383 | voip2 | voipq4 |
    Local/03_voip2@ExternalCallFromQueue | 0 | NULL |
    | 2384 | 3131313131 | voipq4 |
    Local/04_3131313131@ExternalCallFromQueue | 0 | NULL |
    +———-+————-+————–+——————————————–+———+——–+

    How can I make the queue members to be logged in to the call queue for accepting calls ?

    Kind regards,

    Jonas.

  • From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Jonas Kellens Sent: Wednesday, February 12, 2014 3:46 AM
    To: Asterisk Users Mailing List – Non-Commercial Discussion Subject: [asterisk-users] Realtime Call Queues : call members in certain order

    Hello,

    I’m using MySQL realtime Call Queues (table queues and table queue_members).

    I would like to ring the members of the call queue in a certain order. Therefore I use ring strategy lineair and I put the members into the table queue_members in the order in which they have to be rang.

    So I have the queue :

    | name | musicclass | announce | context | timeout | monitor_type | monitor_format | queue_youarenext | queue_thereare | queue_callswaiting | queue_holdtime | queue_minutes | queue_seconds | queue_lessthan | queue_thankyou | queue_reporthold | announce_frequency | announce_round_seconds | announce_holdtime | announce_position | retry | wrapuptime | maxlen | servicelevel | strategy | joinempty | leavewhenempty | eventmemberstatus | eventwhencalled | reportholdtime | memberdelay | weight | timeoutrestart | periodic_announce | periodic_announce_frequency | ringinuse |
    +—————-+————+———-+———+———+————–+—————-+——————+—————-+——————–+—————-+—————+—————+—————-+—————-+——————+——————–+————————+——————-+——————-+——-+————+——–+————–+———-+———–+—————-+——————-+—————–+—————-+————-+——–+—————-+——————-+—————————–+———–+
    | queue6 | default | NULL | | 12 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 30 | NULL | No | yes | 5 | 10 | 0 | NULL | linear | strict | strict | NULL | NULL | NULL | NULL | NULL | no | | 0 | no |
    +—————-+————+———-+———+———+————–+—————-+——————+—————-+——————–+—————-+—————+—————+—————-+—————-+——————+——————–+————————+——————-+——————-+——-+————+——–+————–+———-+———–+—————-+——————-+—————–+—————-+————-+——–+—————-+——————-+—————————–+———–+

    and queue members :

    +———-+—————-+—————-+——————–+———+——–+
    | uniqueid | membername | queue_name | interface | penalty | paused |
    +———-+—————-+—————-+——————–+———+——–+
    | 44 | queuemem4 | queue6 | SIP/queuemem4 | 0 | NULL |
    | 45 | queuemem2 | queue6 | SIP/queuemem2 | 0 | NULL |
    | 46 | queuemem5 | queue6 | SIP/queuemem5 | 0 | NULL |
    | 47 | queuemem1 | queue6 | SIP/queuemem1 | 0 | NULL |
    | 48 | queuemem10 | queue6 | SIP/queuemem10 | 0 | NULL |
    | 49 | queuemem18 | queue6 | SIP/queuemem18 | 0 | NULL |
    | 50 | queuemem17 | queue6 | SIP/queuemem17 | 0 | NULL |
    | 51 | queuemem12 | queue6 | SIP/queuemem12 | 0 | NULL |
    | 52 | queuemem16 | queue6 | SIP/queuemem16 | 0 | NULL |
    | 53 | queuemem13 | queue6 | SIP/queuemem13 | 0 | NULL |
    +———-+—————-+—————-+——————–+———+——–+

    You can see that the member queuemem4 is first in line to be rang (has the first and lowest uniqueid in the table).

    But the first member that is being rang, is queuemem1. How come ??

    Kind regards,

    Jonas.

    Jonas, We encountered the same problem. It is a bug in the Queue application. The Queue application actually orders members by their interface value. Here is the bug report I opened https://issues.asterisk.org/jira/browse/ASTERISK-18480 which was closed as “Not A Bug” by Digium. We worked around this by prepending an integer (001__, 002__, …) to the interface in the database table and then removing it later in the dial plan. Hope this helps. Steven Wheeler

    Hello,

    thank you for your reply.

    Is it the “membername” or the “interface” that needs to be sorted to have a certain order in the call queue ?

    How do you remove the prefix (integer) from a call queue member from dialplan ?

    If you call the queue in your dialplan as follow :

    exten => s,n,Queue(${queuename},,,,${timeout})

    How can you “edit” its members ??

    Kind regards,

    Jonas.

    Jonas, When asterisk queries the database for queue members it sorts the results based on the value of the interface column. We use local channels for calling agents (i.e. Local/001__agent@queue_calling/n) so your mileage may vary. To strip off the prefix we have the following in our queue_calling context.
    [queue_calling]
    exten => _XXX__[A-Za-z0-9*#].,1,Goto(${EXTEN:5},1)
    exten => _[A-Za-z0-9*#].,1,…
    … Logic to call the agent’s SIP phone …

    Hello,

    I have tried this logic with Local channels and a prefix for sorting in the database, but this creates another problem :

    Seemingly my Call Queue is empty, because I get a QUEUESTATUS = JOINEMPTY

    This is now my data in my table :

    +———-+————-+————–+——————————————–+———+——–+
    | uniqueid | membername | queue_name | interface | penalty | paused |
    +———-+————-+————–+——————————————–+———+——–+
    | 2381 | 3232323232 | voipq4 | Local/01_3232323232@ExternalCallFromQueue | 0 | NULL |
    | 2382 | voip1 | voipq4 | Local/02_voip1@ExternalCallFromQueue | 0 | NULL |
    | 2383 | voip2 | voipq4 | Local/03_voip2@ExternalCallFromQueue | 0 | NULL |
    | 2384 | 3131313131 | voipq4 | Local/04_3131313131@ExternalCallFromQueue | 0 | NULL |
    +———-+————-+————–+——————————————–+———+——–+

    How can I make the queue members to be logged in to the call queue for accepting calls ?

    Kind regards,

    Jonas.

    Jonas, It looks like you are missing the state_interface column. Try adding it with this:
    ALTER TABLE `

    ` ADD COLUMN `state_interface` varchar(128) DEFAULT NULL AFTER `interface`;
    You will need to specify a hint for each member, something like:
    hint:@
    Steven