Index: trunk/extensions/DonationInterface/donationinterface.php |
— | — | @@ -356,6 +356,7 @@ |
357 | 357 | $wgStompServer = ""; |
358 | 358 | //$wgStompQueueName = ""; //only set this with an actual value. Default is unset. |
359 | 359 | //$wgPendingStompQueueName = ""; //only set this with an actual value. Default is unset. |
| 360 | + //$wgLimboStompQueueName = ""; //only set this with an actual value. Default is unset. |
360 | 361 | } |
361 | 362 | |
362 | 363 | //Extras globals - required for ANY optional class that is considered an "extra". |
— | — | @@ -508,6 +509,7 @@ |
509 | 510 | $wgHooks['ParserFirstCallInit'][] = 'efStompSetup'; |
510 | 511 | $wgHooks['gwStomp'][] = 'sendSTOMP'; |
511 | 512 | $wgHooks['gwPendingStomp'][] = 'sendPendingSTOMP'; |
| 513 | + $wgHooks['gwLimboStomp'][] = 'sendLimboSTOMP'; |
512 | 514 | } |
513 | 515 | |
514 | 516 | //Custom Filters hooks |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -2015,6 +2015,11 @@ |
2016 | 2016 | } |
2017 | 2017 | } |
2018 | 2018 | |
| 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 | + |
2019 | 2024 | protected function pre_process_get_orderstatus(){ |
2020 | 2025 | if ( $this->getData_Raw( 'payment_method' ) === 'cc' ){ |
2021 | 2026 | $this->runPreProcessHooks(); |
— | — | @@ -2053,5 +2058,40 @@ |
2054 | 2059 | $result = $avs_map[$this->getData_Raw( 'avs_result' )]; |
2055 | 2060 | return $result; |
2056 | 2061 | } |
| 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'; |
2057 | 2078 | |
| 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 | + } |
2058 | 2098 | } |
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php |
— | — | @@ -115,6 +115,47 @@ |
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
| 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 | +/** |
119 | 160 | * Assign correct values to the array of data to be sent to the ActiveMQ server |
120 | 161 | * TODO: Probably something else. I don't like the way this works and neither do you. |
121 | 162 | * |