/**
  * Consume messages from all queues, configured for the given store.
  * @param Mage_Core_Model_Store $store
  * @return self
  */
 protected function _consumeStoreQueues(Mage_Core_Model_Store $store)
 {
     // consume messages from each queue configured within the scope of the store
     foreach ($this->_helper->getConfigModel($store)->queueNames as $queueName) {
         $this->_consumeQueue($queueName, $store);
     }
     return $this;
 }
 /**
  * Return config values that may vary by website/store for the given
  * website.
  * @param  Mage_Core_Model_Website $website
  * @return array Config values for store id, AMQP username and AMQP password
  */
 public function getWebsiteLevelAmqpConfigurations(Mage_Core_Model_Website $website)
 {
     $storeIdPath = $this->_coreConfigMap->getPathForKey(self::STORE_ID_CONFIG_KEY);
     $usernamePath = $this->_amqpConfigMap->getPathForKey(self::USERNAME_CONFIG_KEY);
     $passwordPath = $this->_amqpConfigMap->getPathForKey(self::PASSWORD_CONFIG_KEY);
     $defaultCoreConfig = $this->_coreHelper->getConfigModel(Mage::app()->getStore(0));
     $defaultAmqpConfig = $this->_helper->getConfigModel(Mage::app()->getStore(0));
     // get website level config values, falling back to any not available to the
     // website with default store config values
     return array('store_id' => $website->getConfig($storeIdPath) ?: $defaultCoreConfig->storeId, 'username' => $website->getConfig($usernamePath) ?: $defaultAmqpConfig->username, 'password' => $this->_mageHelper->decrypt($website->getConfig($passwordPath)) ?: $defaultAmqpConfig->password);
 }
 /**
  * Validate the hostname, username and password all appear valid.
  * @param string $hostname
  * @param string $username
  * @param string $password
  * @throws EbayEnterprise_Amqp_Exception_Connection_Exception
  * @return self
  */
 protected function _validateConnection($hostname, $username, $password)
 {
     $queues = $this->_helper->getConfigModel($this->_store)->queueNames;
     if (!$queues) {
         throw Mage::exception('EbayEnterprise_Amqp_Exception_Configuration', $this->_helper->__(self::NO_QUEUES_CONFIGURED));
     }
     // try to connect using the first configured queue - which one it is doesn't
     // matter much as no messages will be consumed
     $amqpApi = $this->_helper->getSdkAmqp(current($queues), $this->_store, $hostname, $username, $password);
     try {
         $amqpApi->openConnection();
     } catch (ConnectionError $e) {
         $logData = ['error_message' => $e->getMessage()];
         $logMessage = 'Failed to connect to AMQP server with message: {error_message}';
         $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData, $e));
     }
     if (!$amqpApi->isConnected()) {
         throw Mage::exception('EbayEnterprise_Amqp_Exception_Connection', $this->_helper->__(self::CONNECTION_FAILED));
     }
     return $this;
 }