Procházet zdrojové kódy

add log to monitor queue

stanley-king před 3 roky
rodič
revize
6c44f71371
2 změnil soubory, kde provedl 11 přidání a 5 odebrání
  1. 8 2
      helper/queue/iqueue.php
  2. 3 3
      rdispatcher/processor.php

+ 8 - 2
helper/queue/iqueue.php

@@ -72,7 +72,8 @@ class IQueueDB
         try {
             return $this->_redis->rPush($this->_queue_name, $value);
         } catch(Exception $e) {
-            throw_exception($e->getMessage());
+            Log::record("IQueueDB::rpush " . $e->getMessage(),Log::ERR);
+            return false;
         }
     }
 
@@ -81,7 +82,8 @@ class IQueueDB
         try {
             return $this->_redis->lPush($this->_queue_name,$value);
         } catch(Exception $e) {
-            throw_exception($e->getMessage());
+            Log::record("IQueueDB::lpush " . $e->getMessage(),Log::ERR);
+            return false;
         }
     }
 
@@ -233,6 +235,10 @@ abstract class ILooper
                         $content = $this->mServer->pop($queues,1);
                         if(empty($content)) continue;
 
+                        $msg = json_encode($content);
+                        Log::record("messge:{$msg}",Log::DEBUG);
+
+
                         if($this->_stop)
                         {
                             foreach ($content as $key => $params) {

+ 3 - 3
rdispatcher/processor.php

@@ -33,7 +33,6 @@ class processor extends queue\ILooper
                 } elseif ($method == 'notify') {
                     $channel = $params['channel'];
                     $input = $params['params'];
-
                     if (empty($channel) || empty($params))
                         continue;
                     $this->mProxy->notify($channel, $input);
@@ -58,8 +57,9 @@ class processor extends queue\ILooper
                 } else {
                     Log::record("Error Method={$method}", Log::DEBUG);
                 }
-            } catch (Exception $x) {
-                Log::record($x->getMessage(), Log::ERR);
+            }
+            catch (Exception $x) {
+                Log::record("processor::handle ". $x->getMessage(), Log::ERR);
             }
         }