Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2.  
  3. class LetterCarrier extends AbstractCarrier {
  4.  
  5. public function __construct($queueName = , $host = 'localhost', $port = 5672, $username = 'guest', $password = 'guest') {
  6. parent::__construct($queueName, $host, $port, $username, $password);
  7. }
  8.  
  9. protected function receivedParcel($msg) {
  10. /* @param AMQPMessage $msg */
  11.  
  12. /* get the parcel by unserializing the meesage body */
  13. $parcel = unserialize($msg->body);
  14.  
  15. /* check that the parcel is a Slack carrot */
  16. if ($parcel instanceof LetterParcel) {
  17. /* @var $parcel \Franklin\Parcels\LetterParcel */
  18. /* do stuff with parcel */
  19. echo "The message in the letter is: {$parcel->getMessage()}";
  20. }else{
  21. echo 'The parcel is not a LetterParcel. Unsure how to handle.';
  22. }
  23.  
  24. // Acknowledge the message so that it's removed from the queue
  25. $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
  26.  
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement