-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from queue-interop/subscription-consumer
Add subscription consumer interface
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
namespace Interop\Queue; | ||
|
||
interface PsrSubscriptionConsumer | ||
{ | ||
/** | ||
* @param float|int $timeout Milliseconds 1000 is 1 second, a zero is consume endlessly. | ||
*/ | ||
public function consume($timeout = 0); | ||
|
||
/** | ||
* Notify broker that the client is interested in consuming messages from this queue. | ||
* | ||
* A callback function to which the consumed message will be passed. | ||
* The function must accept at a minimum one parameter, an \Interop\Queue\PsrMessage object, | ||
* and an optional second parameter the \Interop\Queue\PsrConsumer from which the message was | ||
* consumed. The consumer will not return the processing thread back to | ||
* the PHP script until the callback function returns FALSE. | ||
* | ||
* @param PsrConsumer $consumer | ||
* @param callable $callback | ||
* | ||
* @return void | ||
*/ | ||
public function subscribe(PsrConsumer $consumer, callable $callback); | ||
|
||
/** | ||
* @param PsrConsumer $consumer | ||
* | ||
* @return void | ||
*/ | ||
public function unsubscribe(PsrConsumer $consumer); | ||
|
||
/** | ||
* Unsubscribe all subscribed consumers. | ||
* | ||
* @return void | ||
*/ | ||
public function unsubscribeAll(); | ||
} |
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,10 @@ | ||
<?php | ||
namespace Interop\Queue; | ||
|
||
interface PsrSubscriptionConsumerAwareContext | ||
{ | ||
/** | ||
* @return PsrSubscriptionConsumer | ||
*/ | ||
public function createSubscriptionConsumer(); | ||
} |