diff --git a/app/Amqp/Consumer/ImMessageConsumer.php b/app/Amqp/Consumer/ImMessageConsumer.php index af0a9f4..54dbefd 100644 --- a/app/Amqp/Consumer/ImMessageConsumer.php +++ b/app/Amqp/Consumer/ImMessageConsumer.php @@ -12,7 +12,7 @@ use Hyperf\Amqp\Message\Type; use Hyperf\Amqp\Builder\QueueBuilder; /** - * @Consumer(name="IM信息消费") + * @Consumer(name="IM信息消费",enable=true) */ class ImMessageConsumer extends ConsumerMessage { @@ -38,6 +38,9 @@ class ImMessageConsumer extends ConsumerMessage */ public $routingKey = 'consumer:im:message'; + /** + * ImMessageConsumer constructor. + */ public function __construct() { $this->setQueue('im:message:queue:'.config('ip_address')); @@ -76,8 +79,10 @@ class ImMessageConsumer extends ConsumerMessage return Result::ACK; } - public function isEnable(): bool - { - return true; // TODO: Change the autogenerated stub + /** + * @param $data + */ + public function getClientFds($data){ + } } diff --git a/app/Amqp/Producer/DemoProducer.php b/app/Amqp/Producer/DemoProducer.php index 333162b..ad5f53c 100644 --- a/app/Amqp/Producer/DemoProducer.php +++ b/app/Amqp/Producer/DemoProducer.php @@ -28,6 +28,14 @@ class DemoProducer extends ProducerMessage public function __construct($data) { + $message = [ + 'method'=>'', // + 'sender'=>'', // 发送者 + 'receive'=>'', // 接收者 + 'receiveType'=>'', + 'message'=>[] + ]; + $this->payload = $data; } } diff --git a/app/Controller/IndexController.php b/app/Controller/IndexController.php index 70b8865..f5ec443 100644 --- a/app/Controller/IndexController.php +++ b/app/Controller/IndexController.php @@ -13,9 +13,6 @@ namespace App\Controller; use Hyperf\HttpServer\Contract\ResponseInterface; -use Hyperf\Amqp\Producer; -use App\Amqp\Producer\DemoProducer; - class IndexController extends AbstractController { public function index(ResponseInterface $response) @@ -23,9 +20,6 @@ class IndexController extends AbstractController $user = $this->request->input('user', 'Hyperf'); $method = $this->request->getMethod(); - $producer = container()->get(Producer::class); - $producer->produce(new DemoProducer('test'. date('Y-m-d H:i:s'))); - return [ 'method' => $method, 'message' => "Hello {$user}." diff --git a/config/autoload/server.php b/config/autoload/server.php index 53bfa1a..c9c7efd 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -40,7 +40,7 @@ return [ ], 'settings' => [ 'enable_coroutine' => true, - 'worker_num' => 1, + 'worker_num' => swoole_cpu_num(), 'pid_file' => BASE_PATH . '/runtime/hyperf.pid', 'open_tcp_nodelay' => true, 'max_coroutine' => 100000, @@ -48,6 +48,7 @@ return [ 'max_request' => 100000, 'socket_buffer_size' => 3 * 1024 * 1024, 'buffer_output_size' => 3 * 1024 * 1024, + 'package_max_length'=> 10 * 1024 * 1024, ], 'callbacks' => [ SwooleEvent::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], diff --git a/upload-test.html b/upload-test.html index 58a7688..4785587 100644 --- a/upload-test.html +++ b/upload-test.html @@ -15,15 +15,16 @@ var i = 0; var func = function () { - if (i >= 20) {return;} + if (i >= 2000) {return;} $.ajax({ - url: 'http://47.105.180.123:9503/upload', + url: 'http://127.0.0.1:9503/upload', data: fileData, dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 processData: false, success: function () { + i++; func(); } })