Ejemplo n.º 1
0
 /**
  * @param $queue_key
  * @return array
  */
 private function getQueueConfig($queue_key)
 {
     $queue_config = array_merge(['fetch_count' => 1, 'connection_type' => 'stream', 'max_messages_per_consume' => 1, 'max_time_per_consume' => 600], $this->config->getQueueConfig($queue_key));
     foreach (['host', 'port', 'username', 'password', 'queue_name'] as $key) {
         if (empty($queue_config[$key])) {
             throw new LogicException("The queue config must contain a '{$key}' config.");
         }
     }
     return $queue_config;
 }
Ejemplo n.º 2
0
 /**
  * @param ConfigInterface $mq_config
  * @return FactoryInterface
  * @throws Exception
  */
 public function getAdapter(ConfigInterface $mq_config)
 {
     $config = $mq_config->getAdapterFactoryConfig();
     if (empty($config['type'])) {
         throw new Exception("The message queue 'type' must provided in connection config.");
     }
     if ('testing' === $config['type']) {
         return $this->getTestingFactory($mq_config, $config);
     }
     if ('amqp' === $config['type']) {
         return new AmqpFactory($mq_config);
     }
     throw new Exception("A message queue adapter factory is not associated with '{$config['type']}'.");
 }