public function getQueueByWeight()
    {
        $weights = array_map(function(QueueInterface $queue) {
            return $queue->getWeight();
        }, $this->getQueues());

        $rand = mt_rand(1, array_sum($weights));

        /** @var Queue $queue */
        foreach ($this->getQueues() as $queue) {
            $rand -= $queue->getWeight();
            if ($rand <= 0) {
                $this->logDebug('Queue "'. strtoupper($queue->getName()) .'" selected by weight.');
                return $queue;
            }
        }
    }
public function getQueueByWeight()
    {
        $weights = array_map(function(QueueInterface $queue) {
            return $queue->getWeight();
        }, $this->getQueues());

        $rand = mt_rand(1, array_sum($weights));

        /** @var Queue $queue */
        foreach ($this->getQueues() as $queue) {
            $rand -= $queue->getWeight();
            if ($rand <= 0) {
                $this->logDebug('Queue "'. strtoupper($queue->getName()) .'" selected by weight.');
                return $queue;
            }
        }
    }
public function getQueueByWeight ( ) { $ weights = array_map ( function ( QueueInterface $ queue ) { return $ queue -> getWeight ( ) ; } , $ this -> getQueues ( ) ) ; $ rand = mt_rand ( 1 , array_sum ( $ weights ) ) ; /** @var Queue $queue */ foreach ( $ this -> getQueues ( ) as $ queue ) { $ rand -= $ queue -> getWeight ( ) ; if ( $ rand <= 0 ) { $ this -> logDebug ( 'Queue "' . strtoupper ( $ queue -> getName ( ) ) . '" selected by weight.' ) ; return $ queue ; } } }
Gets random queue based on weight.

For example, an array like ['A'=>5, 'B'=>45, 'C'=>50] means that "A" has a 5% chance of being selected, "B" 45%, and "C" 50%.
The values are simply relative to each other. If one value weight was 2, and the other weight of 1,
the value with the weight of 2 has about a 66% chance of being selected.

@deprecated
@return QueueInterface
Gets random queue based on weight .