r104503 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104502‎ | r104503 | r104504 >
Date:23:12, 28 November 2011
Author:khorn
Status:ok (Comments)
Tags:
Comment:
Establishes a 'limbo' queue for data that GlobalCollect is either extremely likely, or completely guaranteed to bifurcate and/or otherwise mangle before handing it back to us (if they bother to do that bit at all).
This by itself should not be allowed anywhere near production! So don't do it.
Modified paths:
  • /trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php (modified) (history)
  • /trunk/extensions/DonationInterface/donationinterface.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/donationinterface.php
@@ -356,6 +356,7 @@
357357 $wgStompServer = "";
358358 //$wgStompQueueName = ""; //only set this with an actual value. Default is unset.
359359 //$wgPendingStompQueueName = ""; //only set this with an actual value. Default is unset.
 360+ //$wgLimboStompQueueName = ""; //only set this with an actual value. Default is unset.
360361 }
361362
362363 //Extras globals - required for ANY optional class that is considered an "extra".
@@ -508,6 +509,7 @@
509510 $wgHooks['ParserFirstCallInit'][] = 'efStompSetup';
510511 $wgHooks['gwStomp'][] = 'sendSTOMP';
511512 $wgHooks['gwPendingStomp'][] = 'sendPendingSTOMP';
 513+ $wgHooks['gwLimboStomp'][] = 'sendLimboSTOMP';
512514 }
513515
514516 //Custom Filters hooks
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -2015,6 +2015,11 @@
20162016 }
20172017 }
20182018
 2019+ protected function post_process_insert_orderwithpayment(){
 2020+ //yeah, we absolutely want to do this for every one of these.
 2021+ $this->doLimboStompTransaction();
 2022+ }
 2023+
20192024 protected function pre_process_get_orderstatus(){
20202025 if ( $this->getData_Raw( 'payment_method' ) === 'cc' ){
20212026 $this->runPreProcessHooks();
@@ -2053,5 +2058,40 @@
20542059 $result = $avs_map[$this->getData_Raw( 'avs_result' )];
20552060 return $result;
20562061 }
 2062+
 2063+ /**
 2064+ * Function that adds a stomp message to a special 'limbo' queue, for data
 2065+ * that is either highly likely or completely guaranteed to be bifurcated by
 2066+ * handing the ball to a third-party process.
 2067+ * No need to override doStompTransaction in the parent class, as that has
 2068+ * more logic than we need here. However, we may consider functionalizing
 2069+ * some of the copied code in the parent class.
 2070+ * @return void
 2071+ */
 2072+ protected function doLimboStompTransaction() {
 2073+ if ( !$this->getGlobal( 'EnableStomp' ) ){
 2074+ return;
 2075+ }
 2076+ $this->debugarray[] = "Attempting Limbo Stomp Transaction!";
 2077+ $hook = 'gwLimboStomp';
20572078
 2079+ // send the thing.
 2080+ $transaction = array(
 2081+ 'response' => $this->getTransactionMessage(),
 2082+ 'date' => time(),
 2083+ 'gateway_txn_id' => $this->getTransactionGatewayTxnID(),
 2084+ 'correlation-id' => 'GC-' . $this->getData_Raw('order_id'),
 2085+ );
 2086+
 2087+ $stomp_fields = $this->dataObj->getStompMessageFields();
 2088+ foreach ($stomp_fields as $field){
 2089+ $transaction[$field] = $this->getData_Raw($field);
 2090+ }
 2091+
 2092+ try {
 2093+ wfRunHooks( $hook, array( $transaction ) );
 2094+ } catch ( Exception $e ) {
 2095+ self::log( "STOMP ERROR. Could not add message. " . $e->getMessage() , LOG_CRIT );
 2096+ }
 2097+ }
20582098 }
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
@@ -115,6 +115,47 @@
116116 }
117117
118118 /**
 119+ * Hook to send transaction information to ActiveMQ server
 120+ * TODO: Seriously. Parameterize sendStomp. I hated this when there were only
 121+ * two of them, and now I've made another one.
 122+ * THE ONLY THING this does differently, is use a different queue, and set the
 123+ * correlation-id if one is set in the transaction array.
 124+ * @global string $wgStompServer ActiveMQ server name.
 125+ * @global string $wgLimboStompQueueName Name of the destination queue for
 126+ * 'limbo' transactions.
 127+ * @param array $transaction Key-value array of staged and ready donation data.
 128+ * @return bool Just returns true all the time. Presumably an indication that
 129+ * nothing exploded big enough to kill the whole thing.
 130+ */
 131+function sendLimboSTOMP( $transaction ) {
 132+ global $wgStompServer, $wgLimboStompQueueName;
 133+
 134+ $queueName = isset( $wgLimboStompQueueName ) ? $wgLimboStompQueueName : 'test';
 135+
 136+ // include a library
 137+ require_once( "Stomp.php" );
 138+
 139+ $message = json_encode( createQueueMessage( $transaction ) );
 140+
 141+ // make a connection
 142+ $con = new Stomp( $wgStompServer );
 143+
 144+ // connect
 145+ $con->connect();
 146+
 147+ // send a message to the queue
 148+ $result = $con->send( "/queue/$queueName", $message, array( 'persistent' => 'true', 'correlation-id' => $transaction['correlation-id'] ) );
 149+
 150+ if ( !$result ) {
 151+ wfDebugLog( 'activemq_stomp', 'Send to Q failed for this message: ' . $message );
 152+ }
 153+
 154+ $con->disconnect();
 155+
 156+ return true;
 157+}
 158+
 159+/**
119160 * Assign correct values to the array of data to be sent to the ActiveMQ server
120161 * TODO: Probably something else. I don't like the way this works and neither do you.
121162 *

Sign-offs

UserFlagDate
Kaldariinspected18:23, 5 December 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r104539More changes for the 'limbo' queue functionality....khorn03:08, 29 November 2011
r104588r104503, r104539...khorn20:38, 29 November 2011
r104648followup r104503, r104539, r104588...khorn02:54, 30 November 2011
r104791Another round of preparatory limbo stomp changes....khorn23:45, 30 November 2011
r105350MFT r104225, r104471, r104503, r104539, r104588, r104600, r104607, r104648, ...khorn21:12, 6 December 2011
r105351MFT r104225, r104471, r104503, r104539, r104588, r104600, r104607, r104648, ...khorn21:12, 6 December 2011

Comments

#Comment by Kaldari (talk | contribs)   18:25, 5 December 2011

I'm not very familiar with the Stomp processing, so I just marked inspected.

Status & tagging log