Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gggeek
committed
Sep 1, 2015
1 parent
0ce0ab3
commit d0febe1
Showing
6 changed files
with
140 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace Kaliop\Queueing\Plugins\KinesisBundle\Adapter\Kinesis; | ||
|
||
use Kaliop\QueueingBundle\Queue\MessageProducerInterface; | ||
use Aws\Kinesis\KinesisClient; | ||
|
||
class Producer implements MessageProducerInterface | ||
{ | ||
/** @var \Aws\Kinesis\KinesisClient */ | ||
protected $client; | ||
protected $streamName; | ||
protected $debug; | ||
|
||
/** | ||
* @param array $config - minimum seems to be: 'credentials', 'region', 'version' | ||
* @see \Aws\AwsClient::__construct for the full list | ||
* @see http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/configuration.html | ||
*/ | ||
public function __construct(array $config) | ||
{ | ||
$this->client = new KinesisClient($config); | ||
} | ||
|
||
/** | ||
* @param string $queueName | ||
* @todo test that we can successfully send messages to 2 queues using the same KinesisClient | ||
*/ | ||
public function setQueueName($queueName) | ||
{ | ||
$this->streamName = $queueName; | ||
} | ||
|
||
/** | ||
* Note that this has less effect than passing a 'debug' option in constructor, as it will be | ||
* only used by publish() from now on | ||
* | ||
* @param bool $debug use null for 'undefined' | ||
*/ | ||
public function setDebug($debug) | ||
{ | ||
$this->debug = $debug; | ||
} | ||
|
||
/** | ||
* Publishes the message and does what he wants with the properties | ||
* | ||
* @param string $msgBody | ||
* @param string $routingKey | ||
* @param array $additionalProperties | ||
*/ | ||
public function publish($msgBody, $routingKey = '', $additionalProperties = array()) | ||
{ | ||
//try { | ||
$result = $this->client->putRecord(array_merge( | ||
array( | ||
'StreamName' => $this->streamName, | ||
'Data' => $msgBody, | ||
'PartitionKey' => $routingKey | ||
), | ||
$this->getClientParams() | ||
)); | ||
//} catch (\Exception $e) { | ||
// throw new KinesisProxyException($e->getMessage(), $e->getCode(), $e); | ||
//} | ||
//return $result; | ||
} | ||
|
||
protected function getClientParams() | ||
{ | ||
if ($this->debug !== null) { | ||
return array('@http' => array('debug' => $this->debug)); | ||
} | ||
|
||
return array(); | ||
} | ||
|
||
/** | ||
* Does nothing | ||
* @param string $contentType | ||
*/ | ||
public function setContentType($contentType) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# to be maybe replaced with proper semantic config? | ||
|
||
parameters: | ||
kaliop_queueing_kinesis.default.client_config: | ||
credentials: | ||
key: "" | ||
secret: "" | ||
# @see http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.Common.Enum.Region.html | ||
region: "us-east-1" | ||
# NB: It is recommended to fix a specific version for production | ||
version: "latest" | ||
# to get even more debug info that is available via command line switches, use: | ||
#debug: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
# Kaliop Queueing Bundle - Kinesis plugin | ||
|
||
Adds support for AWS Kinesis to https://github.com/kaliop-uk/kueueingbundle | ||
Adds support for AWS Kinesis to the Kaliop Queueing Bundle | ||
|
||
See: http://aws.amazon.com/kinesis/ and https://github.com/kaliop-uk/kueueingbundle respectively. | ||
|
||
It has been given its own bundle because it has higher requirements than the base Queueing Bundle | ||
|
||
## Installation | ||
|
||
1. Install the bundle. | ||
|
||
3. Enable the KaliopQueueingPluginsKinesisBundle bundle in your kernel class registerBundles(). | ||
|
||
4. Clear all caches if not on a dev environment | ||
|
||
5. If you do not have an AWS account, sign up for one at http://aws.amazon.com/ | ||
NB: note that there is no free tier for Kinesis. Pricing is described at: http://aws.amazon.com/kinesis/pricing/ | ||
|
||
## Usage | ||
|
||
* Set up configuration according to your AWS account - see parameters.yml in this bundle | ||
|
||
* To create a kinesis stream, use the web interface: https://console.aws.amazon.com/kinesis/home | ||
|
||
* When running the kaliop_queueing:queuemessage, usage of the -k option to specify a shard is mandatory |