public function start(ZendQueue $q)
 {
     $db = Loader::db();
     $r = $db->Execute('select Users.uID from Users where uIsActive = 1 order by uID asc');
     while ($row = $r->FetchRow()) {
         $q->send($row['uID']);
     }
 }
 public function start(ZendQueue $q)
 {
     $this->is = new IndexedSearch();
     $attributes = CollectionAttributeKey::getList();
     $attributes = array_merge($attributes, FileAttributeKey::getList());
     $attributes = array_merge($attributes, UserAttributeKey::getList());
     foreach ($attributes as $ak) {
         $ak->updateSearchIndex();
     }
     $db = Loader::db();
     $db->Execute('truncate table PageSearchIndex');
     $r = $db->Execute('select Pages.cID from Pages left join CollectionSearchIndexAttributes csia on Pages.cID = csia.cID where (ak_exclude_search_index is null or ak_exclude_search_index = 0) and cIsActive = 1');
     while ($row = $r->FetchRow()) {
         $q->send($row['cID']);
     }
 }
Beispiel #3
0
 /**
  * Send a message to the queue
  *
  * @param  \ZendQueueTest\Custom\Message|\ZendQueueTest\Custom\Messages $message message
  * @return $this
  * @throws Zend_Queue_Exception
  */
 public function send($message)
 {
     if (!($message instanceof Message || $message instanceof Messages)) {
         throw new \ZendQueue\Exception('$message must be an instance of \\ZendQueueTest\\Custom\\Message or \\ZendQueueTest\\Custom\\Messages');
     }
     if ($message instanceof Message) {
         $response = parent::send($message->__toString());
     } else {
         foreach ($message as $i => $one) {
             $response = parent::send($one->__toString());
         }
     }
     return $this;
 }
 /**
  * Get messages of the queue.
  *
  * @param int             $maxMessages
  * @param int             $timeout
  * @param ZendQueue\Queue $queue
  * @param int             $microtime
  */
 protected function getMessages($maxMessages, $timeout, $queue = null, $microtime = null)
 {
     if ($maxMessages === null) {
         $maxMessages = 1;
     }
     if ($timeout === null) {
         $timeout = self::RECEIVE_TIMEOUT_DEFAULT;
     }
     $andWhere = '';
     if ($queue instanceof Queue) {
         $andWhere = 'AND (m.queue = :queue)';
     }
     // Search for all messages inside the timeout
     $sql = 'SELECT m ' . 'FROM Heri\\Bundle\\JobQueueBundle\\Entity\\Message m ' . 'LEFT JOIN m.queue q ' . 'WHERE (m.handle IS NULL OR m.handle = \'\' OR m.timeout + :timeout < :microtime) ' . $andWhere . ' ' . 'ORDER BY m.priority DESC';
     $query = $this->em->createQuery($sql);
     $query->setParameter('timeout', (int) $timeout);
     $query->setParameter('microtime', (int) $microtime);
     if ($queue instanceof Queue) {
         $query->setParameter('queue', $this->getQueueEntity($queue->getName()));
     }
     $query->setMaxResults($maxMessages);
     return $query->getResult();
 }
 /**
  * Create a new message.
  *
  * @param ZendQueue\Queue $queue
  * @param string          $body
  */
 protected function createMessage(Queue $queue, $body)
 {
     // check if message exist
     $message = $this->em->getRepository('Heri\\Bundle\\JobQueueBundle\\Entity\\Message')->findOneBy(['md5' => md5($body)]);
     if (!$message) {
         $message = new \Heri\Bundle\JobQueueBundle\Entity\Message();
         $message->setQueue($this->getQueueEntity($queue->getName()));
         $message->setBody($body);
         $message->setMd5(md5($body));
         $message->setPriority($this->priority);
         $message->setFailed(false);
         $message->setEnded(false);
         $this->em->persist($message);
         $this->em->flush();
         $this->em->clear();
     }
     return $message;
 }
Beispiel #6
0
 public function testActivemqAdapterShouldReturnNoMessagesWhenZeroCountRequested()
 {
     if (!defined('TESTS_ZEND_QUEUE_ACTIVEMQ_ENABLED') || !constant('TESTS_ZEND_QUEUE_ACTIVEMQ_ENABLED')) {
         $this->markTestSkipped('Zend_Queue ActiveMQ adapter tests are not enabled');
     }
     $driverOptions = array();
     if (defined('TESTS_ZEND_QUEUE_ACTIVEMQ_HOST')) {
         $driverOptions['host'] = TESTS_ZEND_QUEUE_ACTIVEMQ_HOST;
     }
     if (defined('TESTS_ZEND_QUEUE_ACTIVEMQ_PORT')) {
         $driverOptions['port'] = TESTS_ZEND_QUEUE_ACTIVEMQ_PORT;
     }
     if (defined('TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME')) {
         $driverOptions['scheme'] = TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME;
     }
     $options = array('driverOptions' => $driverOptions);
     $queue = new Queue('Activemq', $options);
     $queue2 = $queue->createQueue('queue');
     $queue->send('My Test Message 1');
     $queue->send('My Test Message 2');
     $messages = $queue->receive(0);
     $this->assertEquals(0, count($messages));
 }
Beispiel #7
0
 /**
  * Subscribes the client to the queue.
  *
  * @param  \ZendQueue\Queue $queue
  * @return void
  */
 protected function subscribe(Queue $queue)
 {
     $frame = $this->_client->createFrame();
     $frame->setCommand('SUBSCRIBE');
     $frame->setHeader('destination', $queue->getName());
     $frame->setHeader('ack', 'client');
     $this->_client->send($frame);
     $this->_subscribed[$queue->getName()] = TRUE;
 }