Ejemplo n.º 1
2
 /**
  * @expectedException \Aws\Sqs\Exception\SqsException
  * @expectedExceptionMessage Body MD5 mismatch for
  */
 public function testValidatesSuccessfulMd5OfBody()
 {
     $mock = new MockPlugin(array(Response::fromMessage("HTTP/1.1 200 OK\r\nContent-Type: application/xml\r\n\r\n" . "<ReceiveMessageResponse>\n                  <ReceiveMessageResult>\n                    <Message>\n                      <MD5OfBody>fooo</MD5OfBody>\n                      <Body>This is a test message</Body>\n                    </Message>\n                  </ReceiveMessageResult>\n                </ReceiveMessageResponse>")));
     $sqs = SqsClient::factory(array('key' => 'abc', 'secret' => '123', 'region' => 'us-east-1'));
     $sqs->addSubscriber($mock);
     $sqs->receiveMessage(array('QueueUrl' => 'http://foo.com'));
 }
Ejemplo n.º 2
1
 /**
  * Connect to the queueing server. (AWS, Iron.io and Beanstalkd)
  * @param array $config
  * @return
  */
 public function openConnection($config)
 {
     $this->queue = \Aws\Sqs\SqsClient::factory(['credentials' => new \Aws\Common\Credentials\Credentials($config['key'], $config['secret']), 'region' => $config['region']]);
     if (!$this->queue) {
         throw new TestRuntime('connection failed or timed-out.');
     }
 }
Ejemplo n.º 3
0
 function __construct()
 {
     $this->CI =& get_instance();
     $this->client = SqsClient::factory(array('key' => $this->CI->config->item('sqs_access_key_id'), 'secret' => $this->CI->config->item('sqs_secret_key'), 'region' => $this->CI->config->item('aws_region')));
     $this->uuid = $this->CI->config->item('uuid');
     $this->queue = $this->CI->config->item('sqs_queue');
 }
Ejemplo n.º 4
0
 public function testGetQueueArn()
 {
     $url = 'https://sqs.us-east-1.amazonaws.com/057737625318/php-integ-sqs-queue-1359765974';
     $arn = 'arn:aws:sqs:us-east-1:057737625318:php-integ-sqs-queue-1359765974';
     $sqs = SqsClient::factory(array('region' => 'us-east-1'));
     $this->assertEquals($arn, $sqs->getQueueArn($url));
 }
Ejemplo n.º 5
0
 /**
  * Get the Aws Client instance
  * 
  * @return Aws\Sqs\SqsClient
  */
 public function getConnection()
 {
     //we have a stored connection
     if (!$this->_sqsClient) {
         $_config = $this->_getConfiguration();
         $this->_sqsClient = SqsClient::factory(array('key' => $_config['key'], 'secret' => $_config['secret'], 'region' => $_config['region']));
     }
     return $this->_sqsClient;
 }
 public function connect(AwsSqsConfigInterface $config)
 {
     $this->service = SqsClient::factory(array('credentials' => array('key' => $config->getAccessKey(), 'secret' => $config->getSecretKey()), 'region' => $config->getRegion()));
     /*
     
             //var_dump();
             var_dump($response);
     echo $queueUrl;
     */
 }
Ejemplo n.º 7
0
 /**
  *  Setup Sqs Client
  *
  * @param null $url
  * @throws SqsException
  */
 public function __construct($url)
 {
     $this->url = $url;
     if (empty($this->url)) {
         throw new SqsException('No SQS url specified.');
     }
     /**
      * Get client
      */
     $this->client = SqsClient::factory(["key" => AWS_TEAM_COMMUNICATION_KEY, "secret" => AWS_TEAM_COMMUNICATION_SECRET, 'region' => AWS_TEAM_COMMUNICATION_TABLE_REGION]);
 }
 /**
  * @inheritdoc
  */
 public function connect()
 {
     if ($this->instance !== null) {
         $this->instance = null;
         // close previous connection
     }
     $key = $this->getConfigurationValue('key');
     $secret = $this->getConfigurationValue('secret');
     $region = $this->getConfigurationValue('region');
     $this->instance = SqsClient::factory(['key' => $key, 'secret' => $secret, 'region' => $region]);
     return $this;
 }
Ejemplo n.º 9
0
 /**
  * Connect to the queueing server. (AWS, Iron.io and Beanstalkd)
  * @param array $config
  * @return
  */
 public function openConnection($config)
 {
     $params = ['region' => $config['region']];
     if (!empty($config['key']) && !empty($config['secret'])) {
         $params['credentials'] = new Credentials($config['key'], $config['secret']);
     }
     if (!empty($config['profile'])) {
         $params['profile'] = $config['profile'];
     }
     $this->queue = SqsClient::factory($params);
     if (!$this->queue) {
         throw new TestRuntime('connection failed or timed-out.');
     }
 }
Ejemplo n.º 10
0
 /**
  * Gets the configured client connection to SQS. If none is set, it will create
  * a new one out of the configuration stored using the Configure class. It is also
  * possible to provide you own client instance already configured and initialized.
  *
  * @param SqsClient $client if set null current configured client will be used
  *  if set to false, currently configured client will be destroyed
  **/
 public function client($client = null)
 {
     if ($client instanceof SqsClient) {
         $this->_client = $client;
     }
     if ($client === false) {
         return $this->_client = null;
     }
     if (empty($this->_client)) {
         $config = Configure::read('SQS');
         $this->_client = SqsClient::factory($config['connection']);
     }
     return $this->_client;
 }
Ejemplo n.º 11
0
 /**
  * Tests client method
  *
  * @return void
  */
 public function testClient()
 {
     Configure::write('SQS', array('connection' => array('key' => 'a', 'secret' => 'b', 'region' => 'us-east-1')));
     $queue = new SimpleQueue();
     $client = $queue->client();
     $this->assertInstanceOf('\\Aws\\Sqs\\SqsClient', $client);
     $this->assertSame($client, $queue->client());
     $queue->client(false);
     $client2 = $queue->client();
     $this->assertInstanceOf('\\Aws\\Sqs\\SqsClient', $client2);
     $this->assertNotSame($client, $client2);
     $client3 = SqsClient::factory(Configure::read('SQS.connection'));
     $queue->client($client3);
     $this->assertSame($client3, $queue->client());
 }
 protected function registerConnections()
 {
     /*
      * SQS
      */
     $this->app->bind('bernard.connection.sqs', function (Container $app) {
         return \Aws\Sqs\SqsClient::factory(['key' => config('bernard.drivers.sqs.connection.key'), 'secret' => config('bernard.drivers.sqs.connection.secret'), 'region' => config('bernard.drivers.sqs.connection.region')]);
     });
     /*
      * IronMQ
      */
     $this->app->bind('bernard.connection.ironmq', function (Container $app) {
         return new \IronMQ(['token' => config('bernard.drivers.ironmq.connection.token'), 'project_id' => config('bernard.drivers.ironmq.connection.project_id')]);
     });
     /*
      * Predis
      */
     $this->app->bind('bernard.connection.predis', function (Container $app) {
         $host = config('bernard.drivers.predis.connection.host');
         $options = config('bernard.drivers.predis.connection.options');
         return new \Predis\Client($host, $options);
     });
     /*
      * RabbitMQ
      */
     $this->app->bind('bernard.connection.rabbitmq', function (Container $app) {
         $host = config('bernard.drivers.rabbitmq.connection.host');
         $port = config('bernard.drivers.rabbitmq.connection.port');
         $username = config('bernard.drivers.rabbitmq.connection.username');
         $password = config('bernard.drivers.rabbitmq.connection.password');
         return new \PhpAmqpLib\Connection\AMQPStreamConnection($host, $port, $username, $password);
     });
     /*
      * Redis
      */
     $this->app->bind('bernard.connection.redis', function (Container $app) {
         $host = config('bernard.drivers.redis.connection.host');
         $post = config('bernard.drivers.redis.connection.port');
         $prefix = config('bernard.drivers.redis.connection.prefix');
         $redis = new \Redis();
         $redis->connect($host, $post);
         $redis->setOption(\Redis::OPT_PREFIX, $prefix);
         return $redis;
     });
 }
Ejemplo n.º 13
0
 /**
  * Constructor
  *
  * @param string $uri - Uri. Eg: http://sqs.ap-southeast-1.amazonaws.com/71203182391283/sample-queue
  */
 public function __construct($uri)
 {
     $parts = parse_url($uri);
     $this->scheme = @$parts['scheme'] ?: 'https';
     $hParts = explode('.', $parts['host'], 3);
     $this->region = @$hParts[1] ?: 'ap-southeast-1';
     $accessKey = @$parts['user'] ?: '';
     $accessSecret = @$parts['pass'] ?: '';
     $this->sqs = SqsClient::factory(array('key' => $accessKey, 'secret' => $accessSecret, 'region' => $this->region));
     if ($path = ltrim(@$parts['path'], '/')) {
         $pParts = explode('/', $path, 2);
         $this->accountId = $pParts[0];
         if (count($pParts) > 1 && ($queueName = $pParts[1])) {
             if (in_array(substr($queueName, -1), array('-', '_'))) {
                 parent::__construct($queueName);
             } else {
                 $this->setQueueName($queueName);
             }
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * Establish a queue connection.
  *
  * @param  array  $config
  * @return \Illuminate\Queue\QueueInterface
  */
 public function connect(array $config)
 {
     $sqs = SqsClient::factory($config);
     return new SqsQueue($sqs, $config['queue']);
 }
Ejemplo n.º 15
0
 /**
  * Connect to the queueing server. (AWS, Iron.io and Beanstalkd)
  */
 private function _openConnection()
 {
     $this->debug('');
     switch (strtolower($this->config['type'])) {
         case 'aws':
         case 'sqs':
         case 'aws_sqs':
             $this->queue = \Aws\Sqs\SqsClient::factory(array('credentials' => new \Aws\Common\Credentials\Credentials($this->config['key'], $this->config['secret']), 'region' => $this->config['region'])) or \PHPUnit_Framework_Assert::fail('connection failed or timed-out.');
             break;
         case 'iron':
         case 'iron_mq':
             $this->queue = new \IronMQ(array("token" => $this->config['token'], "project_id" => $this->config['project'], "host" => $this->config['host'])) or \PHPUnit_Framework_Assert::fail('connection failed or timed-out.');
             break;
         default:
             $this->queue = new \Pheanstalk_Pheanstalk($this->config['host'], $this->config['port'], $this->config['timeout']) or \PHPUnit_Framework_Assert::fail('connection failed or timed-out.');
     }
 }
 /**
  * This is the endpoint for Team Communication send submissions
  *
  * First thing it does is to store in the database a record of the communications with each recipient
  * Then it dumps the transaction into DynamoDB
  * Then it creates an event in SQS
  */
 public function sendCommunication()
 {
     $data = json_decode($this->request->data, true);
     $recipients = $data['to'];
     //save team communication object
     $record = [];
     $record['TeamCommunication'] = ['content' => $data['template_content'], 'report' => $data['report'], 'presenter_id' => $data['from_presenter_id']];
     /** Remove recipients who have opted out */
     $this->optoutRecipients($recipients, $data['from_presenter_id']);
     $recipients_to_save = [];
     foreach ($recipients as $recipient) {
         if (!empty($recipient['presenter_id'])) {
             $recipients_to_save[] = ['presenter_id' => $recipient['presenter_id']];
         }
     }
     $record['TeamCommunicationRecipient'] = $recipients_to_save;
     $this->TeamCommunication->create();
     if (!$this->TeamCommunication->saveAll($record, array('deep' => true))) {
         $this->sendError('500', "Failed to save communication records.");
         return;
     }
     $team_communication_record_id = $this->TeamCommunication->id;
     /**
      * For testing purposes emails will be sent to TEST_EMAIL
      * property from bootstrap.  Or qatesting if one is not present.
      */
     if (YOUNIQUE_TESTSERVER === true) {
         $email_vars = [];
         $email_vars[] = $this->getEmailVars($data, $data['to'][1]);
         if (defined('TEST_EMAIL')) {
             $to_email_override = TEST_EMAIL;
         } else {
             $to_email_override = '*****@*****.**';
         }
         $this->sendSuccess($this->sendEmailToMandrill($data, $email_vars, $to_email_override));
         $this->sent($team_communication_record_id);
         return;
     }
     unset($data['to']);
     $dynamo_db_ids = [];
     // dump into DynamoDB
     $recipient_count = count($recipients);
     $chunk = 0;
     do {
         $chunk++;
         $dynamo_entry_id = $team_communication_record_id . "_" . $chunk . "_" . gethostname();
         $payload = array();
         //prepare key/value pairs section
         foreach ($data as $key => $value) {
             if (empty($value)) {
                 continue;
             }
             $payload[$key] = array('S' => utf8_encode((string) $value));
         }
         if (!empty($data['img_url'])) {
             $payload['PROFILEIMAGEURL'] = array('S' => utf8_encode((string) $data['img_url']));
         }
         if (!empty($data['from_first_name'])) {
             $payload['PRESENTER_FNAME'] = array('S' => utf8_encode((string) $data['from_first_name']));
         }
         if (!empty($data['recognized_status'])) {
             $payload['RECOGNIZED_STATUS'] = array('S' => utf8_encode((string) $data['recognized_status']));
         }
         $payload['DATE'] = array('S' => utf8_encode((string) date('m/d/Y')));
         //create a list of maps for each recipient
         $payload['to']['L'] = array();
         $chunk_counter = 0;
         foreach ($recipients as $recipient_key => $recipient) {
             $recipient_count--;
             $recipient_array = array();
             // Add Email Merge variables
             $merge_vars = $this->getEmailVars($data, $recipient);
             $new_recipient = array('name' => $recipient['name'], 'email' => $recipient['email']);
             foreach ($merge_vars['vars'] as $key => $value) {
                 $new_recipient[$value['name']] = $value['content'];
             }
             foreach ($new_recipient as $key => $value) {
                 if (empty($value)) {
                     continue;
                 }
                 $recipient_array[$key] = array('S' => (string) $value);
             }
             unset($recipients[$recipient_key]);
             $payload['to']['L'][$chunk_counter] = array('M' => $recipient_array);
             $chunk_counter++;
             if ($chunk_counter >= 500) {
                 break;
             }
         }
         try {
             $client = DynamoDbClient::factory(array("key" => AWS_TEAM_COMMUNICATION_KEY, "secret" => AWS_TEAM_COMMUNICATION_SECRET, 'region' => AWS_TEAM_COMMUNICATION_TABLE_REGION));
             $client_data = array('TableName' => AWS_TEAM_COMMUNICATION_TABLE_NAME, 'Item' => array('id' => array('S' => (string) $dynamo_entry_id), 'event_name' => array('S' => 'team_communication_send'), 'payload' => array('M' => $payload), 'date' => array('S' => utf8_encode((string) date('Y-m-d H:i:s')))));
             $client->putItem($client_data);
             $dynamo_db_ids[] = $dynamo_entry_id;
         } catch (Exception $e) {
             $this->sendError('500', "Failed to save communication event.");
             //store in api audits
             $this->TeamCommunication->apiLog('na', '0', __FILE__ . __LINE__, 'AWS DynamoDB', $e->getRequest(), $e->getResponse(), '', $new = 1);
             return;
         }
     } while ($recipient_count > 0);
     // send to SQS
     $sqs_message = json_encode(array('team_communication_id' => $team_communication_record_id, 'dynamo_db_id' => $dynamo_db_ids));
     $sqs_client = SqsClient::factory(array("key" => AWS_TEAM_COMMUNICATION_KEY, "secret" => AWS_TEAM_COMMUNICATION_SECRET, 'region' => AWS_TEAM_COMMUNICATION_TABLE_REGION));
     $sqs_client->sendMessage(array('QueueUrl' => AWS_TEAM_COMMUNICATION_SQS_URL, 'MessageBody' => $sqs_message));
     $this->sendSuccess(TRUE);
 }
Ejemplo n.º 17
0
 function run()
 {
     $config = $this->config;
     $context = $this->context;
     /* @var $context ExecutionContext */
     $write = function ($s) {
         echo $s;
     };
     $writeln = function ($s) {
         $d = new \DateTime();
         echo $d->format(\DateTime::ISO8601) . ' ' . $s . "\n";
     };
     $c = $color = new \Colors\Color();
     /* @var $c \Colors\Color */
     $writeln($c('Running agent `' . $this->name)->bold() . '`');
     // generate an array with handlers
     $writeln('Loading handlers');
     $handlers = [];
     $handlersDir = $config->handlers_dir;
     if ($handlersDir) {
         $finder = new \Symfony\Component\Finder\Finder();
         foreach ($finder->in($handlersDir)->name('*.php')->sortByName() as $file) {
             /* @var $file \SplFileInfo */
             $handlerId = $file->getBasename('.php');
             $handler = (include $file);
             $handlers[$handlerId] = $handler;
             $writeln('  setting up handler ' . $color($handlerId)->bold() . $color->yellow(' (in ' . $file . ')'));
             $eventName = SqsEvents::generateEventForAgentId(SqsEvents::EVENT_SQSAGENT_SQSMESSAGERECEIVED, $this->getId());
             $context->getEventDispatcher()->addListener($eventName, function (\T24\Event\SqsMessageReceivedEvent $event) use($write, $writeln, $color, $handler, $handlerId, $eventName) {
                 $writeln($color->bg('blue', $color->white('invoking handler ' . $handlerId . ' for event ' . $eventName)));
                 /* @var Callable $handler */
                 $result = $handler($event);
                 // write comments
                 $comments = $event->getComments();
                 foreach ($comments as $comment) {
                     $writeln($color('  comment: ')->yellow() . $comment);
                 }
                 $writeln('  - handler ' . $handlerId . ' had been invoked.');
                 if ($event->isPropagationStopped()) {
                     $writeln('  - ' . $color->red('the event was stopped from further propagation.'));
                 } else {
                     $writeln('  - the event was not stopped. proceed to next handler');
                 }
                 return $result;
             });
         }
         $writeln('Loaded ' . count($handlers) . '  handlers.');
     } else {
         $writeln('default handlers dir not specified, no handlers defined..');
     }
     // @todo: get aws params.
     $region = '';
     $sqsQueueUrl = '';
     $sqs = SqsClient::factory(['region' => $config->aws_region, 'version' => '2012-11-05', 'credentials' => ['key' => $config->aws_key, 'secret' => $config->aws_secret]]);
     // start the process
     $ttl = (int) $config->ttl;
     $ttl = min($ttl, 300);
     $ttl = max($ttl, 5);
     $sleep = (int) $config->sleep;
     $sleep = min($sleep, $ttl - 5);
     $sleep = max($sleep, 0);
     $stopwatch = new \Symfony\Component\Stopwatch\Stopwatch();
     $b = $stopwatch->start('loop');
     while ($b->getDuration() < $ttl * 1000) {
         // get an sqs message from the queue
         $writeln($c('Polling Sqs for messages'));
         $result = $sqs->receiveMessage(['QueueUrl' => $config->sqs_queue_url, 'AttributeNames' => ['All'], 'MessageAttributeNames' => ['All'], 'MaxNumberOfMessages' => 1]);
         /* @var $result \Aws\Result */
         if (!$result['Messages'] || $result['Messages'] == 0) {
             $writeln($c('no messages found in sqs queue'));
         } else {
             $writeln($c(sprintf('%d message(s) retrieved from queue.', count($result['Messages']))));
             foreach ($result['Messages'] as $message) {
                 // set up an event that the message is received.
                 // the default subscriber will pass the event to the event handlers in the handlers dir
                 $event = new SqsMessageReceivedEvent($context, $message);
                 $context->getEventDispatcher()->dispatch(SqsEvents::EVENT_SQSAGENT_SQSMESSAGERECEIVED, $event);
                 $context->getEventDispatcher()->dispatch(SqsEvents::generateEventForAgentId(SqsEvents::EVENT_SQSAGENT_SQSMESSAGERECEIVED, $this->getId()), $event);
                 /*
                 $context->getEventDispatcher()->dispatch(SqsEvents::EVENT_SQSAGENT_SQSMESSAGEHANDLED, $event2);
                 if ($event->isProcessed()) {
                     $context->getEventDispatcher()->dispatch(SqsEvents::EVENT_SQSAGENT_SQSMESSAGEPROCESSED, $event2);
                 }
                 */
                 if ($event->getRemoveFromQueue()) {
                     $writeln('  - the event handlers indicate the sqs message should  be removed from the queue.');
                     // remove from sqs
                     $sqsMessage = $event->getSqsMessage();
                     $removed = $sqs->deleteMessage(['QueueUrl' => $config->sqs_queue_url, 'ReceiptHandle' => $sqsMessage['ReceiptHandle']]);
                     $writeln('  - ' . ($removed ? $c->green('succesfully removed the message from SQS') : $c->red('failed to remove the message from SQS')));
                 } else {
                     $writeln('  - the event handlers indicate the sqs messageshould not be removed from the queue.');
                 }
             }
         }
         $writeln($color->cyan('sleeping for ' . $sleep . ' seconds'));
         sleep($sleep);
     }
     // end stopwatch while loop
     $writeln('Stopped after ' . (int) ($b->getDuration() / 1000) . ' secs.');
     // send the finish event.
     $event = new \T24\Event\AgentEvent($context);
     $context->getEventDispatcher()->dispatch(SqsEvents::EVENT_SQSAGENT_FINISH, $event);
     $context->getEventDispatcher()->dispatch(SqsEvents::generateEventForAgentId(SqsEvents::EVENT_SQSAGENT_FINISH, $this->getId()), $event);
 }
Ejemplo n.º 18
0
 /**
  * Initialize the queue component.
  * @return void
  */
 public function init()
 {
     parent::init();
     $this->_client = SqsClient::factory($this->config);
 }
Ejemplo n.º 19
0
 /**
  * @param string $key
  * @param string $secret
  * @param string $region
  *
  * @return SqsClient
  */
 public static function createClient($key, $secret, $region = Region::IRELAND)
 {
     $config = new Collection(array(ClientOptions::KEY => $key, ClientOptions::SECRET => $secret, ClientOptions::REGION => $region));
     return SqsClient::factory($config);
 }
Ejemplo n.º 20
0
 function __construct($queueName, array $config)
 {
     $this->queueName = $queueName;
     $this->client = SqsClient::factory($config);
 }
Ejemplo n.º 21
0
 public function actionSqsView()
 {
     $client = SqsClient::factory(Yii::$app->params['awsCredentials']);
     $queueUrl = 'https://sqs.eu-west-1.amazonaws.com/698890433952/GymGeckoSQS';
     $result = $client->receiveMessage(array('QueueUrl' => $queueUrl, 'WaitTimeSeconds' => 10));
     var_dump($result['Messages']);
 }
Ejemplo n.º 22
0
 public function connect()
 {
     $this->_connection = SqsClient::factory($this->config);
     $this->connected = true;
 }
Ejemplo n.º 23
0
function getArt($albums, $quality)
{
    global $request;
    /*
      0 = Low (34)
      1 = Medium (64s)
      2 = Large (126)
      3 = xlarge (300)
    */
    $i = 0;
    $artUrl = null;
    //Create SQS Client to send Messages to be consumed and stored in DB.
    $sqs = SqsClient::factory(array('credentials.cache' => $cache, 'region' => 'eu-west-1'));
    foreach ($albums as $album) {
        $url = $album->{'image'}[$quality]->{'#text'};
        if (strpos($url, 'noimage') != false || strlen($url) < 5) {
            error_log('No album art for - ' . $album->{'artist'}->{'name'} . ' - ' . $album->{'name'});
            continue;
        }
        $artUrl[$i]['artist'] = $album->{'artist'}->{'name'};
        $artUrl[$i]['album'] = $album->{'name'};
        $artUrl[$i]['mbid'] = $album->{'mbid'};
        $artUrl[$i]['playcount'] = $album->{'playcount'};
        $artUrl[$i]['url'] = $url;
        $artUrl[$i]['user'] = $request['user'];
        try {
            $result = $sqs->sendMessage(array('QueueUrl' => 'https://sqs.eu-west-1.amazonaws.com/346795263809/lastfm-albums', 'MessageBody' => json_encode($artUrl[$i])));
        } catch (Exception $e) {
            error_log("SQS Error = " . $artUrl[$i]);
        }
        $i++;
    }
    return $artUrl;
}
Ejemplo n.º 24
0
 /**
  * Connect to the queueing server. (AWS, Iron.io and Beanstalkd)
  * @param array $config
  * @return
  */
 public function openConnection($config)
 {
     $this->queue = \Aws\Sqs\SqsClient::factory(array('credentials' => new \Aws\Common\Credentials\Credentials($config['key'], $config['secret']), 'region' => $config['region'])) or \PHPUnit_Framework_Assert::fail('connection failed or timed-out.');
 }
Ejemplo n.º 25
0
 /**
  * Establish a queue connection.
  *
  * @param  array  $config
  * @return \Illuminate\Queue\QueueInterface
  */
 public function connect(array $config)
 {
     $sqsConfig = array_only($config, array('key', 'secret', 'region', 'default_cache_config'));
     $sqs = SqsClient::factory($sqsConfig);
     return new SqsQueue($sqs, $config['queue']);
 }
Ejemplo n.º 26
0
 public function connect()
 {
     $this->connection = SqsClient::factory(array('key' => $this->sqs_options['key'], 'secret' => $this->sqs_options['secret'], 'region' => $this->region));
     $this->connection->setQueueAttributes(array('QueueUrl' => $this->queue_url, 'Attributes' => $this->attribute_options));
 }
Ejemplo n.º 27
0
/**
 * Must be defined before including bootstrap.php
 * as this is the only custom part in the example.
 */
function get_driver()
{
    $sqs = SqsClient::factory(array('key' => getenv('ACCESS_KEY'), 'secret' => getenv('SECRET_KEY'), 'region' => getenv('SQS_REGION')));
    return new SqsDriver($sqs);
}
Ejemplo n.º 28
-1
 public function __construct($awsConfiguration)
 {
     if (!class_exists('\\Aws\\Sqs\\SqsClient')) {
         throw new \LogicException("Can't find AWS SDK >= 2.0.0");
     }
     $this->sqs = SqsClient::factory($awsConfiguration);
 }
 /**
  * @return $this
  */
 public function connect()
 {
     $this->disconnect();
     $key = $this->getConfigurationValue('key');
     $secret = $this->getConfigurationValue('secret');
     $region = $this->getConfigurationValue('region');
     $this->instance = SqsClient::factory(['key' => $key, 'secret' => $secret, 'region' => $region]);
     return $this;
 }
Ejemplo n.º 30
-1
 /**
  * @param array $config
  * @return SqsClient
  * @throws QueueReaderException
  */
 public function createServiceFromConfig(array $config)
 {
     $hasConfiguration = isset($config['queue_client']['url']) && isset($config['queue_client']['params']) && isset($config['queue_client']['options']);
     if (!$hasConfiguration) {
         throw new QueueReaderException("Unable to find config for sqs client");
     }
     $queueUrl = $config['queue_client']['url'];
     $awsSqsParams = $config['queue_client']['params'];
     $options = $config['queue_client']['options'];
     return new SqsClient(AwsSqsClient::factory($awsSqsParams), $queueUrl, $options);
 }