Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting of M:N relation (many type of messages in many channels) required #223

Open
holdmann opened this issue Nov 8, 2024 · 2 comments

Comments

@holdmann
Copy link
Contributor

holdmann commented Nov 8, 2024

Any queue can has many channels, each of them also can has many types of messages.
Current realization supports only one channel <-> one type of message relation.

Еherefore, when processing a queue messages, they are processed successfully until a message with a different type is received.

Then it throws exception:

In Worker.php line 75:
                                                                                                                                                           
  [Yiisoft\Queue\Exception\JobFailureException]                                                                                                            
  Processing of message #null is stopped because of an exception:                                                                                          
  Argument 1 passed to Kant\PIM\Queue\Job\V2\Product::getIblockId() must be of the type int, null given, called in /docroot/local/php_interfac  
  e/classes/Kant/PIM/Queue/Job/V2/Product.php on line 29.                                                                                                  
                                                                                                                                                           

Exception trace:
  at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Worker/Worker.php:75
 Yiisoft\Queue\Worker\Worker->process() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Queue.php:176
 Yiisoft\Queue\Queue->handle() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Queue.php:96
 Yiisoft\Queue\Queue->Yiisoft\Queue\{closure}() at /docroot/local/modules/artofbx.queue/lib/expansion/yiisoft/queue/bitrixadapter.php:272
 ArtOfBx\Queue\Expansion\Yiisoft\Queue\BitrixAdapter->run() at /docroot/local/modules/artofbx.queue/lib/expansion/yiisoft/queue/bitrixadapter.php:66
 ArtOfBx\Queue\Expansion\Yiisoft\Queue\BitrixAdapter->runExisting() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Queue.php:105
 Yiisoft\Queue\Queue->run() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Command/RunCommand.php:54
 Yiisoft\Queue\Command\RunCommand->execute() at /docroot/local/modules/artofbx.queue/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /docroot/local/modules/artofbx.queue/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at /docroot/local/modules/artofbx.queue/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /docroot/local/modules/artofbx.queue/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /docroot/local/modules/artofbx.queue/tools/console.php:87

In Product.php line 78:
                                                                                                                                                           
  [TypeError]                                                                                                                                              
  Argument 1 passed to Kant\PIM\Queue\Job\V2\Product::getIblockId() must be of the type int, null given, called in /docroot/local/php_interfac  
  e/classes/Kant/PIM/Queue/Job/V2/Product.php on line 29                                                                                                   
                                                                                                                                                           

Exception trace:
  at /docroot/local/php_interface/classes/Kant/PIM/Queue/Job/V2/Product.php:78
 Kant\PIM\Queue\Job\V2\Product->getIblockId() at /docroot/local/php_interface/classes/Kant/PIM/Queue/Job/V2/Product.php:29
 Kant\PIM\Queue\Job\V2\Product->execute() at n/a:n/a
 ReflectionFunction->invokeArgs() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/injector/src/Injector.php:86
 Yiisoft\Injector\Injector->invoke() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Worker/Worker.php:63
 Yiisoft\Queue\Worker\Worker->Yiisoft\Queue\Worker\{closure}() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Middleware/Consume/ConsumeFinalHandler.php:23
 Yiisoft\Queue\Middleware\Consume\ConsumeFinalHandler->handleConsume() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Middleware/Consume/MiddlewareConsumeStack.php:44
 Yiisoft\Queue\Middleware\Consume\MiddlewareConsumeStack->handleConsume() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Middleware/Consume/ConsumeMiddlewareDispatcher.php:46
 Yiisoft\Queue\Middleware\Consume\ConsumeMiddlewareDispatcher->dispatch() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Worker/Worker.php:65
 Yiisoft\Queue\Worker\Worker->process() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Queue.php:176
 Yiisoft\Queue\Queue->handle() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Queue.php:96
 Yiisoft\Queue\Queue->Yiisoft\Queue\{closure}() at /docroot/local/modules/artofbx.queue/lib/expansion/yiisoft/queue/bitrixadapter.php:272
 ArtOfBx\Queue\Expansion\Yiisoft\Queue\BitrixAdapter->run() at /docroot/local/modules/artofbx.queue/lib/expansion/yiisoft/queue/bitrixadapter.php:66
 ArtOfBx\Queue\Expansion\Yiisoft\Queue\BitrixAdapter->runExisting() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Queue.php:105
 Yiisoft\Queue\Queue->run() at /docroot/local/modules/artofbx.queue/vendor/yiisoft/queue/src/Command/RunCommand.php:54
 Yiisoft\Queue\Command\RunCommand->execute() at /docroot/local/modules/artofbx.queue/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /docroot/local/modules/artofbx.queue/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at /docroot/local/modules/artofbx.queue/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /docroot/local/modules/artofbx.queue/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /docroot/local/modules/artofbx.queue/tools/console.php:87

queue:run [-m|--maximum MAXIMUM] [--] [<channel>...]

The main problem is here:

src/Middleware/Consume/ConsumeMiddlewareDispatcher.php on line 43

    public function dispatch(
        ConsumeRequest $request,
        MessageHandlerConsumeInterface $finishHandler
    ): ConsumeRequest {
        if ($this->stack === null) {
            $this->stack = new MiddlewareConsumeStack($this->buildMiddlewares(), $finishHandler);
        }

        return $this->stack->handleConsume($request);
    }

As you can see stack be only null|MiddlewareConsumeStack, instead of it should be MiddlewareConsumeStack[].

Additional info

Q A
Version latest
PHP version 8.1+
Operating system any
@holdmann
Copy link
Contributor Author

holdmann commented Nov 8, 2024

Can be closed, PR added - #224

@xepozz xepozz closed this as completed Nov 9, 2024
@viktorprogger viktorprogger reopened this Nov 24, 2024
@viktorprogger
Copy link
Contributor

I'm not sure the exception you provided is related to this package code:

Argument 1 passed to Kant\PIM\Queue\Job\V2\Product::getIblockId() must be of the type int, null given, called in /docroot/local/php_interface/classes/Kant/PIM/Queue/Job/V2/Product.php on line 29.

null passed to a function which expects int, and strict type checks are enabled.

Why do you think this error is related to the queue package?

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

No branches or pull requests

3 participants