client create
This commit is contained in:
@@ -7,6 +7,8 @@ use ba\Random;
|
||||
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
||||
use support\think\Db;
|
||||
use support\Log;
|
||||
use GatewayClient\Gateway;
|
||||
use support\Redis;
|
||||
|
||||
try {
|
||||
// define('AMQP_DEBUG', true);
|
||||
@@ -55,17 +57,35 @@ use support\Log;
|
||||
'data' => $data
|
||||
];
|
||||
$snd_data_json = json_encode($snd_data);
|
||||
$url = 'http://127.0.0.1:8686/?method=' . $method . '&account='. $send_id .'¶ms=' . $snd_data_json; // 替换为你的服务地址和端口
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
$is_log = true;
|
||||
$curl_error = 'Curl error: ' . curl_error($ch);
|
||||
Gateway::$registerAddress = '127.0.0.1:1238';
|
||||
$res = Gateway::sendToGroup($send_id, $snd_data_json);
|
||||
Log::info('商品更新推送结果-->' . $res);
|
||||
$result = Redis::get($snd_data['send_id']);
|
||||
if($result) {
|
||||
$msg_id_arr = json_decode($result, true);
|
||||
$msg_id_arr_c = count($msg_id_arr);
|
||||
$msg_id_arr[$msg_id_arr_c] = $snd_data;
|
||||
$result_n = json_encode($msg_id_arr);
|
||||
\extend\workermans\model\Base::setredis_new($result_n, $snd_data['send_id']);
|
||||
}else {
|
||||
$params_arr_n[] = $snd_data;
|
||||
print_r('数组-------->' . json_encode($params_arr_n)) . "\r\n";
|
||||
\extend\workermans\model\Base::setredis_new(json_encode($params_arr_n), $snd_data['send_id']);
|
||||
}
|
||||
curl_close($ch);
|
||||
Log::info('内部通讯结果(商品更新)--->' . $output . '通讯ID--->shop_id-->' .$send_id. '---' . date('Y-m-d H:i:s') . "\n");
|
||||
|
||||
|
||||
|
||||
// $url = 'http://127.0.0.1:8686/?method=' . $method . '&account='. $send_id .'¶ms=' . $snd_data_json; // 替换为你的服务地址和端口
|
||||
// $ch = curl_init();
|
||||
// curl_setopt($ch, CURLOPT_URL, $url);
|
||||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
// $output = curl_exec($ch);
|
||||
// if (curl_errno($ch)) {
|
||||
// $is_log = true;
|
||||
// $curl_error = 'Curl error: ' . curl_error($ch);
|
||||
// }
|
||||
// curl_close($ch);
|
||||
// Log::info('内部通讯结果(商品更新)--->' . $output . '通讯ID--->shop_id-->' .$send_id. '---' . date('Y-m-d H:i:s') . "\n");
|
||||
if($is_log) {
|
||||
Db::table('tb_mq_log')->insert([
|
||||
'queue' => $queue,
|
||||
|
||||
Reference in New Issue
Block a user