Ejegg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/301660

Change subject: Move banner history off ActiveMQ
......................................................................

Move banner history off ActiveMQ

Required:
* mirror BH messages to Redis in front-end
* add banner-history and banner-history-damaged data-store entries
  in SmashPig.yaml pointing to Predis backend

Bug: T141555
Change-Id: Ib48a02a26d6ba35064af8f7f1f840f5f222a0ed7
---
M civicrm
M sites/all/modules/queue2civicrm/banner_history/banner_history.module
2 files changed, 19 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/60/301660/1

diff --git a/civicrm b/civicrm
index f6d4fc8..7eddb48 160000
--- a/civicrm
+++ b/civicrm
@@ -1 +1 @@
-Subproject commit f6d4fc89a105c5d64e42c3a97325094bfe7f3c5a
+Subproject commit 7eddb48f27d07d98c5336f922908ac2c4b2cc020
diff --git 
a/sites/all/modules/queue2civicrm/banner_history/banner_history.module 
b/sites/all/modules/queue2civicrm/banner_history/banner_history.module
index 52446d2..17e8736 100644
--- a/sites/all/modules/queue2civicrm/banner_history/banner_history.module
+++ b/sites/all/modules/queue2civicrm/banner_history/banner_history.module
@@ -1,5 +1,5 @@
 <?php
-
+use SmashPig\Core\DataStores\QueueConsumer;
 
 /**
  * Implements hook_menu
@@ -72,12 +72,16 @@
 
        civicrm_initialize();
 
-       $processed = queue2civicrm_stomp()->dequeue_loop(
-               variable_get( 'banner_history_queue', '/queue/banner-history' ) 
,
-               variable_get( 'banner_history_batch', 0 ),
+       $queue = variable_get( 'banner_history_queue', '/queue/banner-history' 
);
+       $damagedQueue = $queue . '-damaged';
+       $qc = new QueueConsumer(
+               $queue,
+               'banner_history_process_message',
                variable_get( 'banner_history_batch_time', 0 ),
-               'banner_history_process_message'
+               variable_get( 'banner_history_batch', 0 ),
+               $damagedQueue
        );
+       $processed = $qc->dequeueMessages();
 
        if ( $processed > 0 ) {
                watchdog( 'banner_history',
@@ -91,21 +95,22 @@
 
 function banner_history_process_message( $msg ) {
 
-       $body = json_decode( $msg->body, true );
-
-       if ( is_null( $body ) ) {
+       if ( is_null( $msg ) ) {
                throw new WmfException( 'BANNER_HISTORY',
-                       'Couldn\'t parse banner history message body.' );
+                       'Empty banner history message.' );
        }
 
-       $bannerHistoryId = $body['banner_history_id'];
-       $contributionTrackingId = $body['contribution_tracking_id'];
-
-       if ( !$bannerHistoryId || !$contributionTrackingId ) {
+       if (
+               empty( $msg['banner_history_id'] ) ||
+               empty( $msg['contribution_tracking_id'] )
+       ) {
                throw new WmfException( 'BANNER_HISTORY',
                        'Missing banner history or contribution tracking ID.' );
        }
 
+       $bannerHistoryId = $msg['banner_history_id'];
+       $contributionTrackingId = $msg['contribution_tracking_id'];
+
        if (
                !is_numeric( $contributionTrackingId ) ||
                !preg_match( '/^[0-9a-f]{16,20}$/', $bannerHistoryId )

-- 
To view, visit https://gerrit.wikimedia.org/r/301660
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib48a02a26d6ba35064af8f7f1f840f5f222a0ed7
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to