/** * Construct */ public function __construct($host = '', $ports = array()) { parent::__construct(); // init shared space // init host address $this->host = $host ? (string) $host : PMS_SERVER_HOST; // init shared ports array $this->ports = $ports ? (array) $ports : Pms_Util::getServerPorts(PMS_SERVER_PORT); // init max process for server $this->setMaxProcess(count($ports)); // clear pid file first // do only once !!! $this->__pid(false); // store parent process pid // do only once !!! $this->__pid(true); }
/** * Construct */ public function __construct($host = '', $ports = array()) { // init host address $this->host = $host ? (string) $host : PMS_SERVER_HOST; // init ports array $this->ports = $ports ? (array) $ports : Pms_Util::getServerPorts(PMS_SERVER_PORT); if (!is_array($this->ports)) { require_once 'Pms/Message/Exception.php'; throw new Pms_Message_Exception('server ports must be an array'); } // init xports array ; for keeping geting msg from not empty client foreach ($this->ports as $port) { $client = Pms_Adaptor::client(array('host' => $this->host, 'port' => $port)); if (!$client->getSize()) { continue; } $this->xports[] = $port; } // get random port number $this->__rand(); }
/** * PMS Framework * * @ignore * @category Pms_Message * @package Pms_Message * @author James.Huang <*****@*****.**> * @version $Id$ */ // could be call by other scripts ; avoid path change require_once realpath(dirname(__FILE__) . '/../etc') . '/config.inc'; require_once 'Pms.php'; $action = $argv[1]; // passed parameter $host = PMS_SERVER_HOST; $ports = Pms_Util::getServerPorts(PMS_SERVER_PORT); $xa = new Pms($host, $ports); $xa->beginTransaction(); // start transaction try { if ($action == 'get') { echo "Deal with the messages : \n"; // deal with messages for ($i = 0; $i < 10; $i++) { var_dump($xa->get()); } } if ($action == 'getback') { echo "Deal with the messages : \n"; // deal with messages for ($i = 0; $i < 10; $i++) {