First, thank you, Ramona, for implementing 'mqueue', and the development team more generally. I got away from 'acc' over the weekend and how use mqueue + rtimer + sqlops for asynchronous CDR logging. Classy!
The question is, there a clean, fast way of checking whether there are more items left in the queue to consume?
I would have thought mq_fetch() would return when there's nothing else left in the queue, but it doesn't; instead, it throws the script into an infinite loop. :-) So, I am using:
route[RECORD_CONSUMER] { while(mq_fetch("somequeue")) {
if(! defined $mqk(somequeue)) break;
# Do things with $mqk(...) and $mqv(...)
} }
Is 'defined' a fast-acting operator within route script? Is there a better way?