function publish_data($data) { //print_r($data);exit; //$ch_arr = array('','tran_pic_exchange','tran_pic_exchange1','tran_pic_exchange2','tran_pic_exchange3','tran_pic_exchange4','tran_pic_exchange5'); //$qu_arr = array('','tran_pic_queue','tran_pic_queue1','tran_pic_queue2','tran_pic_queue3','tran_pic_queue4','tran_pic_queue5'); //$i = rand(1,5); $exchange = 'tran_pic_exchange'; $queue = 'tran_pic_queue'; //$exchange = $ch_arr[$i]; //$queue = $qu_arr[$i]; $conn = new RabbitMQClass(MQ_USER, MQ_PASS, MQ_VHOST, MQ_HOST, MQ_PORT); if (function_exists('write_log')) { write_log('trans_pic_mq/' . date("Y-m-d") . '.txt', date("Y-m-d H:i:s") . ":" . $exchange . "===" . $queue . "===" . $data . "\n"); } $conn->queue_publish($exchange, $data, 'direct'); self::$errCode = 200; self::$errMsg = '推送成功'; return TRUE; }
public function view_markAsRead() { $msgids = isset($_POST['msgids']) ? trim($_POST['msgids']) : ''; $type = isset($_POST['type']) ? trim($_POST['type']) : 'read'; //标记类型 $msgids = clearData($msgids); $msg_obj = new messageModel(); $mq_obj = new RabbitMQClass(MQ_USER, MQ_PSW, MQ_VHOST, MQ_SERVER); foreach ($msgids as $idval) { $messageinfo = $msg_obj->getMessageInfo(array($idval)); if (!empty($messageinfo)) { $messageinfo = $messageinfo[0]; $newid = 0; //新的队列主键id //if ($messageinfo['status'] == 0) { $msg_obj->markAaRead($idval, $messageinfo['classid'], $type, $messageinfo['ebay_account'], $newid); //} $mq_obj->queue_publish(MQ_EXCHANGE, array('id' => $newid)); } } $msgdata = array('errCode' => 10020, 'errMsg' => '操作成功'); echo json_encode($msgdata); exit; }
public function reReplyMessage_ebay($ids) { $idsql = implode(',', $ids); $sql = 'select * from msg_message where id in (' . $idsql . ') and status=1 and is_delete =0'; $result = $this->dbconn->fetch_array_all($this->dbconn->query($sql)); // print_r($result);exit; include_once WEB_PATH . 'lib/rabbitmq.class.php'; //消息队列类 $mq_obj = new RabbitMQClass(MQ_USER, MQ_PSW, MQ_VHOST, MQ_SERVER); $failid = array(); foreach ($result as $val) { $sql = "select id from msg_replyqueue where messageid={$val['id']} order by id DESC limit 1"; $row = $this->dbconn->fetch_first($sql); if (empty($row)) { //未找到队列数据 $failid[] = $val['sendid']; } else { $mq_obj->queue_publish(MQ_EXCHANGE, array('id' => $row['id'])); } } return $failid; }
<?php define('SCRIPTS_PATH_CRONTAB', '/data/web/erpNew/pc.valsun.cn/crontab/'); require_once SCRIPTS_PATH_CRONTAB . "scripts.comm.php"; $rabbitMQClass = new RabbitMQClass('xiaojinhua', 'jinhua', '/'); //队列对象 $exchange = 'power'; $queue_name = 'power_pc'; $sqls = $rabbitMQClass->queue_subscribe($exchange, $queue_name, false); $count_sqls = count($sqls); if ($count_sqls == 0) { exit; } echo "已接收队列中 " . $count_sqls . " 条数据\n"; foreach ($sqls as $sql) { // if(get_magic_quotes_gpc())//如果get_magic_quotes_gpc()是打开的 // { //$sql=addslashes($sql);//将字符串进行处理 // } $con_stat = mysql_ping(); echo $sql; echo "\n"; $query = $dbConn->query($sql); if (!$query) { Log::write($con_stat . '---' . $sql, Log::ERR); //Log::write($errorStr,Log::ERR) } else { echo ' [ok] ', $con_stat, '---', $sql, "\n"; } $dbConn->close(); }
function publishMQ($tName, $sql, $serverAddress) { if (C("MQSWITH") == "YES") { require_once WEB_PATH . "lib/rabbitmq/rabbitmq.class.php"; $rabbitMq = new RabbitMQClass(C("MQUSER"), C("MQPSW"), C("MQVHOST"), C("MQSERVERADDRESS")); if ($tName == 'pc_goods' || $tName == 'pc_goods_combine' || $tName == 'pc_sku_combine_relation') { $rabbitMq->queue_publish(C("MQ_EXCHANGE"), $sql); } elseif ($tName == 'pc_sku_conversion') { //料号转换的 $rabbitMq->queue_publish(C("MQ_SKUCONVERSION_EXCHANGE"), $sql); } elseif ($tName == 'pc_goods_category') { $rabbitMq->queue_publish(C("MQ_CATEGROY_EXCHANGE"), $sql); } elseif ($tName == 'pc_goods_partner_relation') { $rabbitMq->queue_publish(C("MQ_GOODSPARTNER_EXCHANGE"), $sql); } } }
/** * 推送重量,运输方式,跟踪号相关信息给订单系统 * @param array $orderDataInfo * @return boolean * @author czq */ public static function pushTransportInfo($orderDataInfo) { $rmq_config = C("RMQ_CONFIG"); $rabbitMQClass = new RabbitMQClass($rmq_config['sendOrder'][1], $rmq_config['sendOrder'][2], $rmq_config['sendOrder'][4], $rmq_config['sendOrder'][0]); //队列对象 $exchange = 'WH_PUSH_ORDER_TRACK'; if ($rabbitMQClass->queue_publish($exchange, json_encode($orderDataInfo), 'direct')) { self::$errMsg = "推送成功!"; return true; } else { self::$errCode = "401"; self::$errMsg = "推送失败!"; return false; } }