public function runTest() { $i = 1; while ($i < 10) { $result = array("key" => 'RCA插头', "index" => 'pro'); writeRMQ("v3www", json_encode($result)); $i++; } }
$cfg = array('host' => '192.168.8.18', 'port' => '5672', 'login' => 'admin', 'password' => 'gc7232275', 'vhost' => '/'); $txonline = new Table("local189"); } else { $cfg = array('host' => '172.17.16.108', 'port' => '5672', 'login' => 'admin', 'password' => 'gc7232275', 'vhost' => '/'); $txonline = new Table("txonline"); } $id = 0; while (1) { $mysqlRs = $txonline->findAll("select cid,province from combusiness.cb_combusiness where cid > '{$id}' order by cid asc limit 100"); if (empty($mysqlRs)) { exit("所有数据处理完毕\n"); } foreach ($mysqlRs as $value) { $id = $value["cid"]; echo getComUrl($value["cid"], $value["province"]); writeRMQ("v3cb", "hy", $id); echo $id, "\n"; } } function getComUrl($cid, $pid) { return "http://company.gongchang.com/p-{$pid}/{$cid}_" . getCombusAuth($cid) . '/'; } function getCombusAuth($cid) { return substr(md5($cid . '$5*uyT^@458,工厂网'), 4, 4); } class Config { public static $dbArr = array('localhost' => array('192.168.12.70', "root", "123456", "test"), 'online' => array('192.168.2.163', "gongchangdb", "gongchangdb7232275", "caijiproductinfo"), 'info' => array('192.168.2.101', 'hangye', 'hangye7232275', 'hangye'), 'local' => array('192.168.8.18', 'root', 'gc7232275', 'gcoperate'), "local170" => array('192.168.8.170', "root", "gc7232275", "test"), 'local189' => array('192.168.8.189', 'gongchang', 'gongchang123', 'gckeyword'), 'main' => array('read.mysql.ch.gongchang.com', 'gcwork', 'gcwork7232275', 'catesearch'), 'maind' => array('write.mysql.ch.gongchang.com', 'gcwork', 'gcwork7232275', 'catesearch'), "product" => array("pdinfo.read.mysql.ch.gongchang.com", "gccontent", "gccontent7232275", "caijiproductinfo"), 'club' => array('55651c3e54ae6.sh.cdb.myqcloud.com', 'cdb_outerroot', 'ScIwH*3fEB(', 'cn_clubnew', 8287), 'txonline' => array('172.17.18.4', 'gckeyword', 'WVwVaxADjX9z3PHd', 'gckeyword')); public static $cateApiUrl = 'http://cate.ch.gongchang.com/cate_json/';
<?php /** * 同类推荐 */ $rs = array('pid' => 900923302, 'cid' => 1968322); writeRMQ('v3www', 'product', json_encode($rs)); /** * 批量打入v3work_seo_pdrec数据,用于预热本企业推荐产品 */ function writeRMQ($exchangeName = 'v3www', $router, $data = '') { $cfg = array('host' => '192.168.8.18', 'port' => '5672', 'login' => 'v3work', 'password' => 'gc7232275', 'vhost' => '/'); if (empty($exchangeName) || empty($data) || empty($cfg)) { return false; } $reTryNum = 3; $errMsg = array(); do { try { //建立到rmq服务器链接 $connection = new AMQPConnection($cfg); $connection->connect(); //建立channel对象 $channel = new AMQPChannel($connection); //建立交换机 $exchange = new AMQPExchange($channel); $exchange->setName($exchangeName); $exchange->setType(AMQP_EX_TYPE_DIRECT); $exchange->setFlags(AMQP_DURABLE); $exchange->declare();
function writeRabbit($i) { writeRMQ('v3cb', 'hy', $i); }