/** * 取得 * @module org.rhaco.store.queue.Queue * @param string $type * @param integer $priority * @throws \org\rhaco\store\queue\exception\NotfoundException */ public function get($type, $priority) { while (true) { try { $object = \org\rhaco\store\queue\module\Dao\QueueDao::find_get(Q::gte('priority', $priority), Q::eq('type', $type), Q::eq('fin', null), Q::eq('lock', null), Q::order('priority,id')); $object->lock(microtime(true)); $object->save(Q::eq('lock', null)); \org\rhaco\store\queue\module\Dao\QueueDao::commit(); return $object->get(); } catch (\org\rhaco\store\db\exception\NoRowsAffectedException $e) { } catch (\org\rhaco\store\db\exception\NotfoundDaoException $e) { throw new \org\rhaco\store\queue\exception\NotfoundException($type . ' not found'); } } }
/** * SmtpBlackholeDaoから送信されたメールの一番新しいものを返す * @param string $to * @param string $subject * @param number $late_time sec * @throws \LogicException * @return \org\rhaco\net\mail\module\SmtpBlackholeDao */ public static function find_mail($to, $keyword = null, $late_time = 60) { if (empty($to)) { throw new \LogicException('`to` not found'); } $result = array(); $q = new Q(); $q->add(Q::eq('to', $to)); $q->add(Q::gte('create_date', time() - $late_time)); if (!empty($subject)) { $q->add(Q::contains('subject', $subject)); } foreach (\org\rhaco\net\mail\module\SmtpBlackholeDao::find($q, Q::order('-id')) as $mail) { $value = $mail->subject() . $mail->message(); if (empty($keyword) || mb_strpos($value, $keyword) !== false) { return $mail; } } throw new \LogicException('指定のメールが飛んでいない > [' . $to . '] ' . $keyword); }