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(); $msg->setType(Pms_Message::MSG_LEVEL_1); $msg->setData("Message IN Queue : " . $xa->port()); $msg = json_encode($msg); // json format data $xa->add($msg); $xa->debug(); } if ($action == 'addback') { echo "Send message : \n"; // deal with messages require_once 'Pms/Message.php'; $msg = new Pms_Message(); $msg->setType(Pms_Message::MSG_LEVEL_1); $msg->setData("Message IN Queue : " . $xa->port()); $msg = json_encode($msg); // json format data $xa->add($msg); $xa->debug(); throw new Exception("Throw Rollback Exception"); } if (!$action || !in_array($action, array('get', 'getback', 'add', 'addback'))) {
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 clear : Clear all message queues