Mwalker has submitted this change and it was merged.
Change subject: API for peeking at head messages in a queue
......................................................................
API for peeking at head messages in a queue
Change-Id: Id40d52d42a2348c15f0252016d55eeb256082f4a
---
M sites/all/modules/wmf_common/Queue.php
1 file changed, 26 insertions(+), 0 deletions(-)
Approvals:
Mwalker: Looks good to me, approved
jenkins-bot: Verified
diff --git a/sites/all/modules/wmf_common/Queue.php
b/sites/all/modules/wmf_common/Queue.php
index 66e4de1..3001f9c 100644
--- a/sites/all/modules/wmf_common/Queue.php
+++ b/sites/all/modules/wmf_common/Queue.php
@@ -115,6 +115,32 @@
unset( $drupal_transaction );
}
+ /**
+ * Preview several messages from the head of a queue, without ack'ing.
+ */
+ function peekMultiple( $queue, $count ) {
+ # TODO: prefetchPolicy, timeout as params?
+
+ $queue = $this->normalizeQueueName( $queue );
+ $con = $this->getFreshConnection();
+
+ $con->setReadTimeout( 1 );
+ # FIXME: probably the wrong value--does this buffer include msgs not
+ # specific to our subscription?
+ $con->prefetchSize = $count;
+
+ $con->subscribe( $queue, array( 'ack' => 'client' ) );
+ $messages = array();
+ while ( $con->hasFrameToRead() && $count-- >= 0 ) {
+ $msg = $con->readFrame();
+ if ( !$msg ) {
+ break;
+ }
+ $messages[] = $msg;
+ }
+ return $messages;
+ }
+
function getByCorrelationId( $queue, $correlationId ) {
$con = $this->getFreshConnection();
$properties = array(
--
To view, visit https://gerrit.wikimedia.org/r/96820
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id40d52d42a2348c15f0252016d55eeb256082f4a
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits