/** * Constructor * * @param array|\Zend\Config\Config $config An array having configuration data * @param \Zend\Queue\Queue The \Zend\Queue\Queue object that created this class * @return void */ public function __construct($options, Queue\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 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') { throw new Queue\Exception("Unable to authenticate to '{$options['scheme']}://{$options['host']}:{$options['port']}'"); } }
/** * Constructor * * @param array|\Traversable $options * @param \Zend\Queue\Queue|null $queue * @return void */ public function __construct($options, Queue $queue = null) { parent::__construct($options, $queue); if (!extension_loaded("jobqueue_client")) { throw new Exception\ExtensionNotLoadedException('Platform Job Queue extension does not appear to be loaded'); } if (!isset($this->_options['daemonOptions'])) { throw new Exception\InvalidArgumentException('Job Queue host and password should be provided'); } $options = $this->_options['daemonOptions']; if (!array_key_exists('host', $options)) { throw new Exception\InvalidArgumentException('Platform Job Queue host should be provided'); } if (!array_key_exists('password', $options)) { throw new Exception\InvalidArgumentException('Platform Job Queue password should be provided'); } $this->_zendQueue = new ZendAPI_Queue($options['host']); if (!$this->_zendQueue) { throw new Exception\ConnectionException('Platform Job Queue connection failed'); } if (!$this->_zendQueue->login($options['password'])) { throw new Exception\ConnectionException('Job Queue login failed'); } if ($this->_queue) { $this->_queue->setMessageClass('\\Zend\\Queue\\Message\\PlatformJob'); } }
/** * Constructor * * @param array|\Zend\Config\Config $options * @param \Zend\Queue\Queue|null $queue * @return void */ public function __construct($options, Queue $queue = null) { parent::__construct($options, $queue); if (!isset($this->_options['options'][Select::FOR_UPDATE])) { // turn off auto update by default $this->_options['options'][Select::FOR_UPDATE] = false; } if (!is_bool($this->_options['options'][Select::FOR_UPDATE])) { throw new QueueException('Options array item: \Zend\Db\Select::FOR_UPDATE must be boolean'); } if (isset($this->_options['dbAdapter']) && $this->_options['dbAdapter'] instanceof AbstractDBAdapter) { $db = $this->_options['dbAdapter']; } else { $db = $this->_initDBAdapter(); } $this->_queueTable = new Db\Queue(array( 'db' => $db, )); $this->_messageTable = new Db\Message(array( 'db' => $db, )); }
/** * Constructor * * @param array|\Traversable $options * @param null|\Zend\Queue\Queue $queue * @return void */ public function __construct($options, Queue $queue = null) { if (!extension_loaded('memcache')) { throw new Exception\ExtensionNotLoadedException('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) { throw new Exception\ConnectionException('Could not connect to MemcacheQ'); } $this->_host = $options['host']; $this->_port = (int)$options['port']; }
/** * Constructor * * @param array|\Zend\Config\Config $options * @param null|\Zend\Queue\Queue $queue * @return void */ public function __construct($options, Queue\Queue $queue = null) { if (!extension_loaded('mongo')) { throw new Queue\Exception('Mongo 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; } if (!array_key_exists('dbname', $options)) { throw new \ArgumentErrorException('No option "dbname"'); } $mongo = new \Mongo('mongodb://' . $options['host'] . ':' . (int) $options['port']); $this->_socket = $mongo->selectDB($options['dbname']); }
/** * Constructor * * @param array|\Zend\Config\Config $options * @param \Zend\Queue\Queue|null $queue * @return void */ public function __construct($options, Queue $queue = null) { parent::__construct($options, $queue); }