forked from onPHP/onphp-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
8 changed files
with
514 additions
and
80 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
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,79 @@ | ||
<?php | ||
/*************************************************************************** | ||
* Copyright (C) 2011 by Sergey S. Sergeev * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
interface AMQPConsumer | ||
{ | ||
/** | ||
* @return AMQPChannelInterface | ||
**/ | ||
public function getChannel(); | ||
|
||
/** | ||
* Called when a delivery appears for this consumer. | ||
* @param AMQPIncomingMessage $delivery | ||
* @return void | ||
**/ | ||
public function handleDelivery(AMQPIncomingMessage $delivery); | ||
|
||
/** | ||
* Called when the consumer is first registered by a call | ||
* to {@link Channel#basicConsume}. | ||
* | ||
* @param consumerTag the defined consumerTag | ||
* @return void | ||
**/ | ||
public function handleConsumeOk($consumerTag); | ||
|
||
/** | ||
* Called when the consumer is deregistered by a call | ||
* to {@link Channel#basicCancel}. | ||
* | ||
* @param consumerTag the defined consumerTag | ||
* @return void | ||
**/ | ||
public function handleCancelOk($consumerTag); | ||
|
||
/** | ||
* @return AMQPConsumer | ||
**/ | ||
public function setQueueName($name); | ||
|
||
/** | ||
* @return string | ||
**/ | ||
public function getQueueName(); | ||
|
||
/** | ||
* @return AMQPConsumer | ||
**/ | ||
public function setAutoAcknowledge($boolean); | ||
|
||
/** | ||
* @return boolean | ||
**/ | ||
public function isAutoAcknowledge(); | ||
|
||
/** | ||
* @return AMQPConsumer | ||
**/ | ||
public function setConsumerTag($consumerTag); | ||
|
||
/** | ||
* @return string | ||
**/ | ||
public function getConsumerTag(); | ||
|
||
/** | ||
* @return AMQPIncomingMessage | ||
**/ | ||
public function getNextDelivery(); | ||
} | ||
?> |
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,116 @@ | ||
<?php | ||
/*************************************************************************** | ||
* Copyright (C) 2011 by Sergey S. Sergeev * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
abstract class AMQPDefaultConsumer implements AMQPConsumer | ||
{ | ||
/** | ||
* @var AMQPChannelInterface | ||
**/ | ||
protected $channel = null; | ||
protected $consumerTag = null; | ||
protected $autoAcknowledge = false; | ||
protected $queueName = null; | ||
|
||
public function __construct(AMQPChannelInterface $channel) | ||
{ | ||
$this->channel = $channel; | ||
} | ||
|
||
/** | ||
* @return AMQPChannelInterface | ||
**/ | ||
public function getChannel() | ||
{ | ||
return $this->channel; | ||
} | ||
|
||
/** | ||
* @param $consumerTag | ||
* @return AMQPConsumer | ||
**/ | ||
public function setConsumerTag($consumerTag) | ||
{ | ||
$this->consumerTag = $consumerTag; | ||
|
||
return $this; | ||
} | ||
|
||
public function getConsumerTag() | ||
{ | ||
return $this->consumerTag; | ||
} | ||
|
||
/** | ||
* @return void | ||
**/ | ||
public function handleConsumeOk($consumerTag) | ||
{ | ||
// no work to do | ||
} | ||
|
||
/** | ||
* @return void | ||
**/ | ||
public function handleCancelOk($consumerTag) | ||
{ | ||
// no work to do | ||
} | ||
|
||
/** | ||
* @return void | ||
**/ | ||
public function handleDelivery(AMQPIncomingMessage $delivery) | ||
{ | ||
// no work to do | ||
} | ||
|
||
/** | ||
* @return AMQPDefaultConsumer | ||
**/ | ||
public function setQueueName($name) | ||
{ | ||
$this->queueName = $name; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
**/ | ||
public function getQueueName() | ||
{ | ||
return $this->queueName; | ||
} | ||
|
||
/** | ||
* @return AMQPDefaultConsumer | ||
**/ | ||
public function setAutoAcknowledge($boolean) | ||
{ | ||
$this->autoAcknowledge = ($boolean === true); | ||
|
||
return $this; | ||
} | ||
|
||
public function isAutoAcknowledge() | ||
{ | ||
return $this->autoAcknowledge; | ||
} | ||
|
||
/** | ||
* @return AMQPIncomingMessage | ||
**/ | ||
public function getNextDelivery() | ||
{ | ||
return $this->channel->getNextDelivery(); | ||
} | ||
} | ||
?> |
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 @@ | ||
<?php | ||
/*************************************************************************** | ||
* Copyright (C) 2011 by Sergey S. Sergeev * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
class AMQPQueueConsumer extends AMQPDefaultConsumer {/**/} | ||
?> |
Oops, something went wrong.