Exemplo n.º 1
0
 /**
  * Constructor
  *
  * @param  array|Zend_Config $options
  * @param  Zend_Queue|null $queue
  * @return void
  */
 public function __construct($options, Zend_Queue $queue = null)
 {
     parent::__construct($options, $queue);
     if (!extension_loaded("jobqueue_client")) {
         require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception('Platform Job Queue extension does not appear to be loaded');
     }
     if (!isset($this->_options['daemonOptions'])) {
         require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception('Job Queue host and password should be provided');
     }
     $options = $this->_options['daemonOptions'];
     if (!array_key_exists('host', $options)) {
         require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception('Platform Job Queue host should be provided');
     }
     if (!array_key_exists('password', $options)) {
         require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception('Platform Job Queue password should be provided');
     }
     $this->_zendQueue = new ZendApi_Queue($options['host']);
     if (!$this->_zendQueue) {
         require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception('Platform Job Queue connection failed');
     }
     if (!$this->_zendQueue->login($options['password'])) {
         require_once PHP_LIBRARY_PATH . 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception('Job Queue login failed');
     }
     if ($this->_queue) {
         $this->_queue->setMessageClass('Zend_Queue_Message_PlatformJob');
     }
 }
Exemplo n.º 2
0
 /**
  * Constructor
  *
  * @param  array|Zend_Config $options
  * @param  null|Zend_Queue $queue
  * @return void
  */
 public function __construct($options, Zend_Queue $queue = null)
 {
     if (!extension_loaded('mongo')) {
         require_once 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception('Mongo extension does not appear to be loaded');
     }
     parent::__construct($options, $queue);
     $options =& $this->_options['driverOptions'];
     if (!array_key_exists('host', $this->_options)) {
         $this->_options['host'] = self::DEFAULT_HOST;
     }
     if (!array_key_exists('port', $this->_options)) {
         $this->_options['port'] = self::DEFAULT_PORT;
     }
     if (!array_key_exists('persistent', $this->_options)) {
         $this->_options['persistent'] = self::DEFAULT_PERSISTENT;
     }
     if (!array_key_exists('dbname', $this->_options)) {
         $this->_options['dbname'] = self::DEFAULT_DBNAME;
     }
     if (!array_key_exists('collection', $this->_options)) {
         $this->_options['collection'] = self::DEFAULT_COLLECTION;
     }
     $options = $this->_options;
     $this->_conn = new Mongo($this->_options['host'], $this->_options['port'], $this->_options['persistent']);
     $this->_db = $this->_conn->selectDB($this->_options['dbname']);
     $result = $this->_collection = $this->_db->selectCollection($this->_options['collection']);
     if ($result === false) {
         require_once 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception('Could not connect to Mongo');
     }
     $this->_host = $options['host'];
     $this->_port = (int) $options['port'];
 }
Exemplo n.º 3
0
 /**
  * Constructor
  *
  * @param  array|Zend_Config $config An array having configuration data
  * @param  Zend_Queue The Zend_Queue object that created this class
  * @return void
  */
 public function __construct($options, Zend_Queue $queue = null)
 {
     parent::__construct($options);
     $options =& $this->_options['driverOptions'];
     if (!array_key_exists('scheme', $options)) {
         $options['scheme'] = self::DEFAULT_SCHEME;
     }
     if (!array_key_exists('host', $options)) {
         $options['host'] = self::DEFAULT_HOST;
     }
     if (!array_key_exists('port', $options)) {
         $options['port'] = self::DEFAULT_PORT;
     }
     if (array_key_exists('stompClient', $options)) {
         $this->_client = $options['stompClient'];
     } else {
         $this->_client = new Zend_Queue_Stomp_Client($options['scheme'], $options['host'], $options['port']);
     }
     $connect = $this->_client->createFrame();
     // Username and password are optional on some messaging servers
     // such as Apache's ActiveMQ
     $connect->setCommand('CONNECT');
     if (isset($options['username'])) {
         $connect->setHeader('login', $options['username']);
         $connect->setHeader('passcode', $options['password']);
     }
     $response = $this->_client->send($connect)->receive();
     if (false !== $response && $response->getCommand() != 'CONNECTED') {
         //require_once 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception("Unable to authenticate to '" . $options['scheme'] . '://' . $options['host'] . ':' . $options['port'] . "'");
     }
 }
Exemplo n.º 4
0
    /**
     * Constructor
     *
     * @param  array|Zend_Config $options
     * @param  null|Zend_Queue $queue
     * @return void
     */
    public function __construct($options, Zend_Queue $queue = null)
    {
        if (!extension_loaded('memcache')) {
            require_once 'Zend/Queue/Exception.php';
            throw new Zend_Queue_Exception('Memcache extension does not appear to be loaded');
        }

        parent::__construct($options, $queue);

        $options = &$this->_options['driverOptions'];

        if (!array_key_exists('host', $options)) {
            $options['host'] = self::DEFAULT_HOST;
        }
        if (!array_key_exists('port', $options)) {
            $options['port'] = self::DEFAULT_PORT;
        }

        $this->_cache = new Memcache();

        $result = $this->_cache->connect($options['host'], $options['port']);

        if ($result === false) {
            require_once 'Zend/Queue/Exception.php';
            throw new Zend_Queue_Exception('Could not connect to MemcacheQ');
        }

        $this->_host = $options['host'];
        $this->_port = (int)$options['port'];
    }
Exemplo n.º 5
0
 /**
  * Constructor
  *
  * @param  array|Zend_Config $options
  * @param  Zend_Queue|null   $queue
  *
  * @return self
  *
  * @throws Zend_Queue_Exception
  */
 public function __construct($options, Zend_Queue $queue = null)
 {
     Zend_Queue_Adapter_AdapterAbstract::__construct($options, $queue);
     if (!isset($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
         // turn off auto update by default
         $this->_options['options'][Zend_Db_Select::FOR_UPDATE] = false;
     }
     if (!is_bool($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
         throw new Zend_Queue_Exception('Options array item: Zend_Db_Select::FOR_UPDATE must be boolean');
     }
     if (!isset($this->_options['dbAdapter']) || !$this->_options['dbAdapter'] instanceof Zend_Db_Adapter_Abstract) {
         throw new Zend_Queue_Exception('dbAdapter must be set');
     }
     if (!isset($this->_options['dbQueueTable']) || empty($this->_options['dbQueueTable'])) {
         throw new Zend_Queue_Exception('dbQueueTable must be set');
     }
     if (!isset($this->_options['dbMessageTable']) || empty($this->_options['dbMessageTable'])) {
         throw new Zend_Queue_Exception('dbMessageTable must be set');
     }
     $db = $this->_options['dbAdapter'];
     $queueTable = $this->_options['dbQueueTable'];
     $messageTable = $this->_options['dbMessageTable'];
     $this->_queueTable = new Zend_Db_Table(array('db' => $db, 'name' => $queueTable, 'primary' => 'queue_id'));
     $this->_messageTable = new Zend_Db_Table(array('db' => $db, 'name' => $messageTable, 'primary' => 'message_id'));
 }
Exemplo n.º 6
0
    /**
     * Constructor
     *
     * @param  array|Zend_Config $options
     * @param  Zend_Queue|null $queue
     * @return void
     */
    public function __construct($options, Zend_Queue $queue = null)
    {
        parent::__construct($options, $queue);

        if (!isset($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
            // turn off auto update by default
            $this->_options['options'][Zend_Db_Select::FOR_UPDATE] = false;
        }

        if (!is_bool($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
            require_once 'Zend/Queue/Exception.php';
            throw new Zend_Queue_Exception('Options array item: Zend_Db_Select::FOR_UPDATE must be boolean');
        }

        if (isset($this->_options['dbAdapter'])
            && $this->_options['dbAdapter'] instanceof Zend_Db_Adapter_Abstract) {
            $db = $this->_options['dbAdapter'];
        } else {
            $db = $this->_initDbAdapter();
        }

        $this->_queueTable = new Zend_Queue_Adapter_Db_Queue(array(
            'db' => $db,
        ));

        $this->_messageTable = new Zend_Queue_Adapter_Db_Message(array(
            'db' => $db,
        ));

    }
Exemplo n.º 7
0
 /**
  * Constructor
  *
  * @param  array|Zend_Config $options
  * @param  null|Zend_Queue $queue
  * @return void
  */
 public function __construct($options, Zend_Queue $queue = null)
 {
     parent::__construct($options, $queue);
     if (!empty($this->_options['driverOptions'])) {
         $this->_rediska = $options['driverOptions'];
     }
     $this->_rediska = Rediska_Options_RediskaInstance::getRediskaInstance($this->_rediska, 'Zend_Queue_Exception', 'driverOptions');
     $this->_queues = new Rediska_Key_Set($this->_getKeyName('queues'), array('rediska' => $this->_rediska));
 }
Exemplo n.º 8
0
 /**
  * Constructor
  *
  * @param  array|Zend_Config $options
  * @param  null|Zend_Queue $queue
  * @return void
  */
 public function __construct($options, Zend_Queue $queue = null)
 {
     parent::__construct($options, $queue);
     $defaultInstance = Rediska::getDefaultInstance();
     if (empty($this->_options['driverOptions']) && $defaultInstance) {
         $this->_rediska = $defaultInstance;
     } else {
         $this->_rediska = new Rediska($this->_options['driverOptions']);
     }
     $this->_queues = new Rediska_Key_Set($this->_getKeyName('queues'));
     $this->_queues->setRediska($this->_rediska);
 }
Exemplo n.º 9
0
 public function __construct($options, Zend_Queue $queue = null)
 {
     $this->_queueModel = isset($options['queue_model']) ? $options['queue_model'] : Mage::getModel('enterprise_queue/queue');
     unset($options['queue_model']);
     $this->_queueTaskModel = isset($options['task_model']) ? $options['task_model'] : Mage::getModel('enterprise_queue/queue_task');
     unset($options['task_model']);
     $this->_queueCollection = isset($options['queue_collection']) ? $options['queue_collection'] : Mage::getResourceModel('enterprise_queue/queue_collection');
     unset($options['queue_collection']);
     $this->_queueTaskCollection = isset($options['queue_task_collection']) ? $options['queue_task_collection'] : Mage::getResourceModel('enterprise_queue/queue_task_collection');
     unset($options['queue_task_collection']);
     $this->_logger = isset($options['logger']) ? $options['logger'] : Mage::getModel('core/logger');
     unset($options['logger']);
     parent::__construct($options, $queue);
 }
Exemplo n.º 10
0
 /**
  * Constructor
  *
  * @param  array|Zend_Config $options
  * @param  Zend_Queue|null $queue
  * @return void
  */
 public function __construct($options, Zend_Queue $queue = null)
 {
     parent::__construct($options, $queue);
     if (!isset($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
         // turn off auto update by default
         $this->_options['options'][Zend_Db_Select::FOR_UPDATE] = false;
     }
     if (!is_bool($this->_options['options'][Zend_Db_Select::FOR_UPDATE])) {
         require_once 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception('Options array item: Zend_Db_Select::FOR_UPDATE must be boolean');
     }
     $options =& $this->_options['driverOptions'];
     if (!array_key_exists('type', $options)) {
         require_once 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception("Configuration array must have a key for 'type' for the database type to use");
     }
     if (!array_key_exists('host', $options)) {
         require_once 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception("Configuration array must have a key for 'host' for the host to use");
     }
     if (!array_key_exists('username', $options)) {
         require_once 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception("Configuration array must have a key for 'username' for the username to use");
     }
     if (!array_key_exists('password', $options)) {
         require_once 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception("Configuration array must have a key for 'password' for the password to use");
     }
     if (!array_key_exists('dbname', $options)) {
         require_once 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception("Configuration array must have a key for 'dbname' for the database to use");
     }
     try {
         $db = Zend_Db::factory($options['type'], $options);
         $this->_queueTable = new Zend_Queue_Adapter_Db_Queue(array('db' => $db));
         $this->_messageTable = new Zend_Queue_Adapter_Db_Message(array('db' => $db));
     } catch (Zend_Db_Exception $e) {
         require_once 'Zend/Queue/Exception.php';
         throw new Zend_Queue_Exception('Error connecting to database: ' . $e->getMessage(), $e->getCode());
     }
 }
Exemplo n.º 11
0
 /**
  * Constructor
  *
  * @param  array|Zend_Config $options
  * @param  null|Zend_Queue $queue
  * @return void
  */
 public function __construct($options, Zend_Queue $queue = null)
 {
     parent::__construct($options, $queue);
 }