oncesk / sqs-wrapper
There is no license information available for the latest version (0.0.2) of this package.
description_text
0.0.2
2014-09-22 17:51 UTC
Requires
- aws/aws-sdk-php: 2.6.16
This package is not auto-updated.
Last update: 2024-11-05 03:28:59 UTC
README
##Installaction
- through composer
$> composer require oncesk/sqs-wrapper dev-master
##Usage
####Push (send) message
<?php use SqsWrapper\Manager; use SqsWrapper\MessageAbstract; class Message extends MessageAbstract { public $test = 1; public $array = array(1, 2); public $bool = true; public $string = 'hello world!'; public $obj; } $client1 = Manager::createClient('KEY', 'SECRET', 'REGION'); $client2 = Manager::createClient('KEY', 'SECRET', \Aws\Common\Enum\Region::IRELAND); $packer = new \SqsWrapper\Packer(); $manager = new Manager($client, 'Your Queue url'); $manager->setPacker($packer); // set packer for encode and decode message $msg = new Message(); $msg->obj = new Message(); $msg->obj->string = 'nested object'; $manager->send($msg); // send message to current queue $manager2 = new Manager($client, 'Your Queue url 2'); $manager2->setPacker($packer); $collection = new \SqsWrapper\ManagerCollection(); $collection ->addManager($manager) ->addManager($manager2); $msg = new Message(); $msg->obj = new Message(); $msg->obj->string = 'nested object'; $collection->send($msg); // send message in few queues
####Receive message
<?php use SqsWrapper\Manager; use SqsWrapper\MessageAbstract; class Message extends MessageAbstract { public $test = 1; public $array = array(1, 2); public $bool = true; public $string = 'hello world!'; public $obj; } $client = Manager::createClient('KEY', 'SECRET', \Aws\Common\Enum\Region::IRELAND); $manager = new Manager($client, 'Your Queue url'); $manager->setPacker(new \SqsWrapper\Packer()); $message = $manager->receive(); print_r($message); // obj instance of Message