Skip to content

如何根据不同环境来设定是否启动 AMQP #3720

Answered by limingxinleo
zxyfaxcn asked this question in Q&A
Discussion options

You must be logged in to vote

这个问题其实很好处理,其他任何类似的问题,都可以通过以下方式解决,让我们先创建一个监听器,监听 BootApplication 事件,然后从注解收集器里把对应的数据打印出来。

<?php

declare(strict_types=1);

namespace App\Listener;

use Hyperf\Amqp\Annotation\Consumer;
use Hyperf\Amqp\Annotation\Producer;
use Hyperf\Di\Annotation\AnnotationCollector;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Framework\Event\BootApplication;
use Psr\Container\ContainerInterface;

#[Listener]
class AMQPCheckListener implements ListenerInterface
{
    /**
     * @var ContainerInterface
     */
    private $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public f…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by limingxinleo
Comment options

You must be logged in to vote
1 reply
@limingxinleo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #3717 on June 21, 2021 08:37.