Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class LetterCarrier extends AbstractCarrier {
- public function __construct($queueName = , $host = 'localhost', $port = 5672, $username = 'guest', $password = 'guest') {
- parent::__construct($queueName, $host, $port, $username, $password);
- }
- protected function receivedParcel($msg) {
- /* @param AMQPMessage $msg */
- /* get the parcel by unserializing the meesage body */
- $parcel = unserialize($msg->body);
- /* check that the parcel is a Slack carrot */
- if ($parcel instanceof LetterParcel) {
- /* @var $parcel \Franklin\Parcels\LetterParcel */
- /* do stuff with parcel */
- echo "The message in the letter is: {$parcel->getMessage()}";
- }else{
- echo 'The parcel is not a LetterParcel. Unsure how to handle.';
- }
- // Acknowledge the message so that it's removed from the queue
- $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement