// 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++) { var_dump($xa->get()); } throw new Exception("Throw Rollback Exception"); } if ($action == 'add') { echo "Send message : \n"; // deal with messages require_once 'Pms/Message.php'; $msg = new Pms_Message();
echo $client->stats(); exit; } // deal with messages if ($action == 'clear') { $client->clear(); exit; } // do all messages one by one if ($action == 'doall') { foreach ($ports as $port) { // find in all pms mqs $client = new Pms($host, $port); // do get all message while ($client->size()) { var_dump($client->get()); $client->debug(); } } exit; } echo <<<USAGE Usage: php client.php <ACTIONS> Actions: send : Send a message to PMS Server recv : Recv a message from PMS Server fill : Fill random messages to the queues doall : Recv all messages one by one stats : Get PMS Server queues stats