This commit is contained in:
12
app/Amqp/Producer/AliSlsProducer.php
Normal file
12
app/Amqp/Producer/AliSlsProducer.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use Hyperf\Amqp\Annotation\Producer;
|
||||
|
||||
#[Producer(exchange: 'wh_ali_sls', routingKey: 'wh_ali_sls_key')]
|
||||
class AliSlsProducer extends BaseProducer
|
||||
{
|
||||
}
|
44
app/Amqp/Producer/BaseProducer.php
Normal file
44
app/Amqp/Producer/BaseProducer.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/6
|
||||
* Time: 上午9:53
|
||||
* Description:
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use App\Context\UserContext;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
|
||||
/**
|
||||
* Author: ykxiao
|
||||
* Date: 2025/6/6
|
||||
* Time: 上午9:57
|
||||
* Description: amqp生产者抽象基类.
|
||||
*
|
||||
* (c) ykxiao <yk_9001@hotmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
abstract class BaseProducer extends ProducerMessage
|
||||
{
|
||||
public function __construct(array $data)
|
||||
{
|
||||
// 设置用户信息上下文信息
|
||||
if (UserContext::hasCurrentUser()) {
|
||||
$data['user'] = UserContext::getCurrentUser();
|
||||
}
|
||||
|
||||
$this->payload = $data;
|
||||
$this->properties['delivery_mode'] = 2; // 消息持久化
|
||||
}
|
||||
}
|
13
app/Amqp/Producer/UserImportProducer.php
Normal file
13
app/Amqp/Producer/UserImportProducer.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use Hyperf\Amqp\Annotation\Producer;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
|
||||
#[Producer(exchange: 'wh_user_import', routingKey: 'wh_user_import_key')]
|
||||
class UserImportProducer extends BaseProducer
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user