Skip to content

Conversation

@holdmann
Copy link

@holdmann holdmann commented Apr 21, 2025

ExchangeDeclaredException commented because prevents several channels usage

Q A
Is bugfix? ✔️

I'm trying to use several channels pushing messages this way

use Yiisoft\Queue as YiiQueue;

class Queue
{
    public static function get(string $channel = YiiQueue\QueueInterface::DEFAULT_CHANNEL): YiiQueue\QueueInterface
    {
        $di = DI\ServiceLocator::getInstance();

        $adapter = $di->get(YiiQueue\Adapter\AdapterInterface::class)
            ->withChannel($channel);
        $queue = $di->get(YiiQueue\Queue::class);

        return $queue->withAdapter($adapter);
    }
}

Queue::get('{custom-channel-name}')->push(/* message */);

Everything is ok here, message successufully pushed to new queue of RabbitMQ.

But when trying to use build-in commands, like listen {custom-channel-name} get ExchangeDeclaredException().
As I discovered while researching the source code problem occurs on line 84 of src/QueueProvider.php because $this->exchangeSettings never equals to null because of default value in __construct().

Used this as hard-fix only

@viktorprogger
Copy link
Contributor

@holdmann Thank you for reporting this issue! It's fixed in #116. It's better to create a ticket for such cases in the future.
You may also @mention me to make processing of your issues and PRs faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants