Hi Marie That's why I asked about thread safety for global vars, cause it was appearing that global variables was going to be the only way to send data between the two instances - e. g. between the running call and the queue-triggered macro.
So the inherited (_ prepend) channel variables are exactly what I needed, e. g. a way to definitively isolate the unique ID for a call from the unique IDs for all other concurrent queued calls when the relevant macro is triggered by users picking up calls in a very busy queue. And I need to pass a variable in from the calling context into the macro being called. So all's good, at least my solution will now start to work in the way I envisioned it to. Thanks! -----Original Message----- From: Marie Fischer <[email protected]> Sent: Friday, 11 May 2018 15:28 To: [email protected]; Asterisk Users Mailing List - Non-Commercial Discussion <[email protected]> Subject: Re: [asterisk-users] Passing parameter to Queue-called macro Hi Stefan, glad you got it solved. Just to clarify, those are not global, but channel variables you are using - so they should be visible only to their respective channel (and child channels with inheritance). Global variables are defined in a [globals] section in extensions.conf. (https://wiki.asterisk.org/wiki/display/AST/Global+Variables+Basics) -- BR, marie On 11.05.2018, at 9:01, Stefan Viljoen <[email protected]> wrote: > 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 <[email protected]> > Sent: Thursday, 10 May 2018 15:08 > To: [email protected]; Asterisk Users Mailing List - > Non-Commercial Discussion <[email protected]> > 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 <[email protected]> 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(accountc >> o >> 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 > > > -- > _____________________________________________________________________ > -- 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 -- _____________________________________________________________________ -- 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
