r104588 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104587‎ | r104588 | r104589 >
Date:20:38, 29 November 2011
Author:khorn
Status:ok (Comments)
Tags:
Comment:
r104503, r104539
More changes for the limbo queue: Finding and acking the old message in real time takes _way_ too long, so we're not going to do that in realtime.
Additional: Some stopwatch / commstats cleanup. Mostly only relevent for batch processes.
Modified paths:
  • /trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -1046,7 +1046,9 @@
10471047 public function do_transaction( $transaction ){
10481048 switch ( $transaction ){
10491049 case 'Confirm_CreditCard' :
1050 - return $this->transactionConfirm_CreditCard();
 1050+ $this->getStopwatch( __FUNCTION__, true );
 1051+ $result = $this->transactionConfirm_CreditCard();
 1052+ $this->saveCommunicationStats( __FUNCTION__, $transaction );
10511053 break;
10521054 default:
10531055 return parent::do_transaction( $transaction );
@@ -1195,21 +1197,10 @@
11961198 }
11971199
11981200 if ( $deletelimbomessageflag ) {
1199 - //ack the message out of the limbo queue.
1200 -
1201 - //TODO: Test this in a batch situation. I have reason to suspect that the selectors won't work if the stomp connection isn't being reset properly.
1202 - $limbo_messages = stompFetchMessages( 'limbo', "JMSCorrelationID = '" . $this->getCorrelationID() . "'" );
1203 - $msgCount = count($limbo_messages);
1204 - if ($msgCount){
1205 - stompAckMessages($limbo_messages);
1206 - if ($msgCount > 1){
1207 - self::log($this->getData_Raw( 'contribution_tracking_id' ) . ':' . $this->getData_Raw( 'order_id' ) . " - Deleted $msgCount limbo messages.");
1208 - }
1209 - } else {
1210 - self::log($this->getData_Raw( 'contribution_tracking_id' ) . ':' . $this->getData_Raw( 'order_id' ) . " - No limbo messages found.");
1211 - }
1212 -
1213 - closeDIStompConnection();
 1201+ //As it happens, we can't remove things from the queue here: It
 1202+ //takes way too dang long. (~5 seconds!)
 1203+ //So, instead, I'll add an anti-message and deal with it later. (~.01 seconds)
 1204+ $this->doLimboStompTransaction( true );
12141205 }
12151206
12161207 if ( $problemflag ){
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -832,14 +832,14 @@
833833
834834 // If the payment processor requires XML, package our data into XML.
835835 if ( $this->getCommunicationType() === 'xml' ) {
836 - $this->getStopwatch( "buildRequestXML" ); // begin profiling
 836+ $this->getStopwatch( "buildRequestXML", true ); // begin profiling
837837 $curlme = $this->buildRequestXML(); // build the XML
838838 $this->saveCommunicationStats( "buildRequestXML", $transaction ); // save profiling data
839839 }
840840
841841 // If the payment processor requires name/value pairs, package our data into name/value pairs.
842842 if ( $this->getCommunicationType() === 'namevalue' ) {
843 - $this->getStopwatch( "buildRequestNameValueString" ); // begin profiling
 843+ $this->getStopwatch( "buildRequestNameValueString", true ); // begin profiling
844844 $curlme = $this->buildRequestNameValueString(); // build the name/value pairs
845845 $this->saveCommunicationStats( "buildRequestNameValueString", $transaction ); // save profiling data
846846 }
@@ -1283,11 +1283,15 @@
12841284
12851285 /**
12861286 *
1287 - * @param type $function
1288 - * @param type $additional
1289 - * @param type $vars
 1287+ * @param string $function This is the function name that identifies the
 1288+ * stopwatch that should have already been started with the getStopwatch
 1289+ * function.
 1290+ * @param string $additional Additional information about the thing we're
 1291+ * currently timing. Meant to be easily searchable.
 1292+ * @param string $vars Intended to be particular values of any variables
 1293+ * that might be of interest.
12901294 */
1291 - function saveCommunicationStats( $function = '', $additional = '', $vars = '' ) {
 1295+ public function saveCommunicationStats( $function = '', $additional = '', $vars = '' ) {
12921296 static $saveStats = null;
12931297 static $saveDB = null;
12941298
@@ -1521,7 +1525,7 @@
15221526 * TODO: Functionalize some of the code copied from doStompTransaction.
15231527 * @return null
15241528 */
1525 - protected function doLimboStompTransaction() {
 1529+ protected function doLimboStompTransaction( $antimessage = false ) {
15261530 if ( !$this->getGlobal( 'EnableStomp' ) ){
15271531 return;
15281532 }
@@ -1530,26 +1534,40 @@
15311535
15321536 $stomp_fields = $this->dataObj->getStompMessageFields();
15331537
1534 - $transaction = array(
1535 - 'response' => $this->getTransactionMessage(),
1536 - 'date' => time(),
1537 - 'gateway_txn_id' => $this->getTransactionGatewayTxnID(),
1538 - 'correlation-id' => $this->getCorrelationID(),
1539 - 'payment_method' => $this->getData_Raw( 'payment_method' )
1540 - );
1541 -
1542 - $raw_data = array();
1543 - foreach ( $stomp_fields as $field ){
1544 - $raw_data[$field] = $this->getData_Raw( $field );
 1538+ if ($antimessage){
 1539+ $transaction = array(
 1540+ 'date' => time(),
 1541+ 'gateway_txn_id' => $this->getTransactionGatewayTxnID(),
 1542+ 'correlation-id' => $this->getCorrelationID(),
 1543+ 'payment_method' => $this->getData_Raw( 'payment_method' ),
 1544+ 'antimessage' => 'true'
 1545+ );
 1546+ } else {
 1547+ $transaction = array(
 1548+ 'response' => $this->getTransactionMessage(),
 1549+ 'date' => time(),
 1550+ 'gateway_txn_id' => $this->getTransactionGatewayTxnID(),
 1551+ 'correlation-id' => $this->getCorrelationID(),
 1552+ 'payment_method' => $this->getData_Raw( 'payment_method' ),
 1553+ );
 1554+
 1555+ $raw_data = array();
 1556+ foreach ( $stomp_fields as $field ){
 1557+ $raw_data[$field] = $this->getData_Raw( $field );
 1558+ }
 1559+ $transaction = array_merge( $raw_data, $transaction );
15451560 }
1546 -
1547 - $transaction = array_merge( $raw_data, $transaction );
15481561
15491562 try {
15501563 wfRunHooks( $hook, array( $transaction ) );
15511564 } catch ( Exception $e ) {
15521565 self::log( "STOMP ERROR. Could not add message. " . $e->getMessage() , LOG_CRIT );
15531566 }
 1567+ if ($antimessage){
 1568+ $antimessage = "Anti-message = true";
 1569+ } else {
 1570+ $antimessage = '';
 1571+ }
15541572 }
15551573
15561574 protected function getCorrelationID(){
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php
@@ -1017,6 +1017,8 @@
10181018 'zip2',
10191019 'gateway',
10201020 'gateway_txn_id',
 1021+ 'payment_method',
 1022+ 'payment_submethod',
10211023 'response',
10221024 'currency_code',
10231025 'amount',
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
@@ -135,19 +135,24 @@
136136 // include a library
137137 require_once( "Stomp.php" );
138138
139 - $message = json_encode( createQueueMessage( $transaction ) );
 139+ $properties = array(
 140+ 'persistent' => 'true',
 141+ 'correlation-id' => $transaction['correlation-id'],
 142+ 'payment_method' => $transaction['payment_method']
 143+ );
 144+
 145+ if ( array_key_exists( 'antimessage', $transaction ) ) {
 146+ $message = '';
 147+ $properties['antimessage'] = 'true';
 148+ } else {
 149+ $message = json_encode( createQueueMessage( $transaction ) );
 150+ }
140151
141152 // make a connection
142153 $con = new Stomp( $wgStompServer );
143154
144155 // connect
145156 $con->connect();
146 -
147 - $properties = array(
148 - 'persistent' => 'true',
149 - 'correlation-id' => $transaction['correlation-id'],
150 - 'payment_method' => $transaction['payment_method']
151 - );
152157
153158 // send a message to the queue
154159 $result = $con->send( "/queue/$queueName", $message, $properties );
@@ -212,6 +217,8 @@
213218 'postal_code_2' => $transaction['zip2'],
214219 'gateway' => $transaction['gateway'],
215220 'gateway_txn_id' => $transaction['gateway_txn_id'],
 221+ 'payment_method' => $transaction['payment_method'],
 222+ 'payment_submethod' => $transaction['payment_submethod'],
216223 'response' => $transaction['response'],
217224 'currency' => $transaction['currency_code'],
218225 'original_currency' => $transaction['currency_code'],

Follow-up revisions

RevisionCommit summaryAuthorDate
r104648followup r104503, r104539, r104588...khorn02:54, 30 November 2011
r104791Another round of preparatory limbo stomp changes....khorn23:45, 30 November 2011
r105263followup r104588...khorn00:29, 6 December 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

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r104503Establishes a 'limbo' queue for data that GlobalCollect is either extremely l...khorn23:12, 28 November 2011
r104539More changes for the 'limbo' queue functionality....khorn03:08, 29 November 2011

Comments

#Comment by Awjrichards (talk | contribs)   00:27, 6 December 2011
+		if ($antimessage){
+			$antimessage = "Anti-message = true";
+		} else {
+			$antimessage = '';
+		}

These lines seem... extraneous, yet harmless.

#Comment by Khorn (WMF) (talk | contribs)   01:07, 6 December 2011

I took 'em out in r105263.

Status & tagging log