Stefan Viljoen
2018-May-08 13:16 UTC
[asterisk-users] Passing parameter to Queue-called macro
Hi all I need to pass a parameter in a thread-safe manner to the Queue pickup macro. This is to know when (and who) picked up an incoming call to a queue and log that to my back-office system with a CURL to a HTTP endpoint. However, the Queue application does not appear to allow passing of parameters to the called queue pickup macro. E. g. non-working code is: [queuetest] timeout = 60 retry = 2 member=>SIP/testnum [macro-verdianswer] exten=>s,1,NoOp(Entering Verdi answer macro) exten=>s,n,NoOp(Value: ${ARG1}) exten=>s,n,MacroExit [incomingcontext] exten=>tstqueue,1,NoOp(Incoming call for VerDi) same=>n,Set(curlResult=${SHELL(/usr/src/verdi/bash/verdiIncGetUUID.sh)}) same=>n,Set(curlResultLength=${LEN(${curlResult})}) same=>n,NoOp(Curl result for incoming call UUID from VerDi: ${curlResult}) same=>n,Set(CDR(accountcode)=${curlResult}) same=>n,Set(curIncAccCode=${curlResult},g) same=>n,Macro(VCRECORD,stefantestEXT${CALLERID(num)}ACC${CDR(accountcode)},$ {EXTEN}) same=>n,Queue(queuetest,trhc,,,60,,verdianswer(${curIncAccCode})) same=>n,Hangup() This results, when executed, in: [May 8 15:14:50] WARNING[20921]: app_macro.c:309 _macro_exec: No such context 'macro-verdianswer(2018050815141huzzu4 ' for macro 'verdianswer(2018050815141huzzu4 How can one pass a paramter into the macro called by the Asterisk queue application on queue pickup? Alternatively, how can a global variable or ASTDB entry be made thread safe to do the same? Thank you Stefan
Marie Fischer
2018-May-10 13:07 UTC
[asterisk-users] Passing parameter to Queue-called macro
Hi, maybe I am overlooking something, but channel variables should be thread safe, shouldn't they? I am using the following (sorry, in ael): macro dial-queue (number) { Set(_ORIG_UNIQUEID=${UNIQUEID}); Queue(${number},rCt,,,${timeout},,set-dst-agent); .. } // the "context macro-..." things is an ael-specific workaround to get transfer working (macro sets context to app_queue_gosub_virtual_context) context macro-set-dst-agent { s => { Noop(${ORIG_UNIQUEID}); &add-current-call-agent(${ORIG_UNIQUEID},${MEMBERNAME}); } } macro add-current-call-agent (id,num) { Set(ODBC_ADD_CURRENT_AGENT(${id},${num})=1); return; } -- marie On 08.05.2018, at 16:16, Stefan Viljoen <viljoens at verishare.co.za> wrote:> Hi all > > I need to pass a parameter in a thread-safe manner to the Queue pickup > macro. This is to know when (and who) picked up an incoming call to a queue > and log that to my back-office system with a CURL to a HTTP endpoint. > > However, the Queue application does not appear to allow passing of > parameters to the called queue pickup macro. > > E. g. non-working code is: > > [queuetest] > timeout = 60 > retry = 2 > member=>SIP/testnum > > [macro-verdianswer] > exten=>s,1,NoOp(Entering Verdi answer macro) > exten=>s,n,NoOp(Value: ${ARG1}) > exten=>s,n,MacroExit > > [incomingcontext] > > exten=>tstqueue,1,NoOp(Incoming call for VerDi) > same=>n,Set(curlResult=${SHELL(/usr/src/verdi/bash/verdiIncGetUUID.sh)}) > same=>n,Set(curlResultLength=${LEN(${curlResult})}) > same=>n,NoOp(Curl result for incoming call UUID from VerDi: ${curlResult}) > same=>n,Set(CDR(accountcode)=${curlResult}) > same=>n,Set(curIncAccCode=${curlResult},g) > same=>n,Macro(VCRECORD,stefantestEXT${CALLERID(num)}ACC${CDR(accountcode)},$ > {EXTEN}) > same=>n,Queue(queuetest,trhc,,,60,,verdianswer(${curIncAccCode})) > same=>n,Hangup() > > This results, when executed, in: > > [May 8 15:14:50] WARNING[20921]: app_macro.c:309 _macro_exec: No such > context 'macro-verdianswer(2018050815141huzzu4 > ' for macro 'verdianswer(2018050815141huzzu4 > > How can one pass a paramter into the macro called by the Asterisk queue > application on queue pickup? > > Alternatively, how can a global variable or ASTDB entry be made thread safe > to do the same? > > Thank you > > Stefan > > > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > Check out the new Asterisk community forum at: https://community.asterisk.org/ > > New to Asterisk? Start here: > https://wiki.asterisk.org/wiki/display/AST/Getting+Started > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users
Stefan Viljoen
2018-May-11 06:01 UTC
[asterisk-users] Passing parameter to Queue-called macro
Hi Marie Thanks! I was just worried about thread safety if I had to use a global variable, e. g. it might be set to a value by one call (since I'm using the same global for every incoming call to transfer the accountcode gotten from my HTTP endpoint to the same macro, and there can be several calls simultaneously all inserting HTTP-sourced values at more or less the same instant) and then another call is in such a state that it then reads this call's data - and never reads its logical "own" data. The classic concurrently accessed single variable issue. Anyway, I've managed to solve this by declaring a variable in the main dialplan as inheritable and storing my back-office relevant GUID in there, then referencing that variable without the pre-prended _ in the macro: E. g. [verdianswer] exten=>s,n,NoOp(Lodging CDR accountcode: ${curIncAccCode} as an incoming call from ${numbersource} with VerDi and answered by ${MEMBERINTERFACE}...) exten=>s,n,MacroExit [telkomin] . . . same=>n,Set(curlResult=${SHELL(/usr/src/verdi/bash/verdiIncGetUUID.sh)}) same=>n,Set(_curIncAccCode=${curlResult}) same=>n,Queue(stefantest,trhc,,,60,,verdianswer) The above works just fine for doing what I want to do, e. g. pass a parameter from an Asterisk dialplan context into a queue-triggered "agent just answered in the queue" Asterisk macro. Thanks for the reply! Kind regards Stefan -----Original Message----- From: Marie Fischer <marie at vtl.ee> Sent: Thursday, 10 May 2018 15:08 To: viljoens at verishare.co.za; Asterisk Users Mailing List - Non-Commercial Discussion <asterisk-users at lists.digium.com> Subject: Re: [asterisk-users] Passing parameter to Queue-called macro Hi, maybe I am overlooking something, but channel variables should be thread safe, shouldn't they? I am using the following (sorry, in ael): macro dial-queue (number) { Set(_ORIG_UNIQUEID=${UNIQUEID}); Queue(${number},rCt,,,${timeout},,set-dst-agent); .. } // the "context macro-..." things is an ael-specific workaround to get transfer working (macro sets context to app_queue_gosub_virtual_context) context macro-set-dst-agent { s => { Noop(${ORIG_UNIQUEID}); &add-current-call-agent(${ORIG_UNIQUEID},${MEMBERNAME}); } } macro add-current-call-agent (id,num) { Set(ODBC_ADD_CURRENT_AGENT(${id},${num})=1); return; } -- marie On 08.05.2018, at 16:16, Stefan Viljoen <viljoens at verishare.co.za> wrote:> Hi all > > I need to pass a parameter in a thread-safe manner to the Queue pickup > macro. This is to know when (and who) picked up an incoming call to a > queue and log that to my back-office system with a CURL to a HTTPendpoint.> > However, the Queue application does not appear to allow passing of > parameters to the called queue pickup macro. > > E. g. non-working code is: > > [queuetest] > timeout = 60 > retry = 2 > member=>SIP/testnum > > [macro-verdianswer] > exten=>s,1,NoOp(Entering Verdi answer macro) > exten=>s,n,NoOp(Value: ${ARG1}) > exten=>s,n,MacroExit > > [incomingcontext] > > exten=>tstqueue,1,NoOp(Incoming call for VerDi) > same=>n,Set(curlResult=${SHELL(/usr/src/verdi/bash/verdiIncGetUUID.sh) > }) > same=>n,Set(curlResultLength=${LEN(${curlResult})}) > same=>n,NoOp(Curl result for incoming call UUID from VerDi: > ${curlResult}) > same=>n,Set(CDR(accountcode)=${curlResult}) > same=>n,Set(curIncAccCode=${curlResult},g) > same=>n,Macro(VCRECORD,stefantestEXT${CALLERID(num)}ACC${CDR(accountco > de)},$ > {EXTEN}) > same=>n,Queue(queuetest,trhc,,,60,,verdianswer(${curIncAccCode})) > same=>n,Hangup() > > This results, when executed, in: > > [May 8 15:14:50] WARNING[20921]: app_macro.c:309 _macro_exec: No such > context 'macro-verdianswer(2018050815141huzzu4 > ' for macro 'verdianswer(2018050815141huzzu4 > > How can one pass a paramter into the macro called by the Asterisk > queue application on queue pickup? > > Alternatively, how can a global variable or ASTDB entry be made thread > safe to do the same? > > Thank you > > Stefan > > > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > Check out the new Asterisk community forum at: > https://community.asterisk.org/ > > New to Asterisk? Start here: > https://wiki.asterisk.org/wiki/display/AST/Getting+Started > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users