enqueue-dev icon indicating copy to clipboard operation
enqueue-dev copied to clipboard

non-static QueueSubscriberInterface::getSubscribedQueues()

Open andreyserdjuk opened this issue 2 years ago • 1 comments

I propose to make this accessor non-static to allow developers build more flexible mechanism of subscription. For example I have code:

abstract class AbstractConsumer implements Processor, QueueSubscriberInterface
{
  // ....
  // ....
    public function process(Message $message, Context $context)
    {
        $event = $this->serializer->deserialize($message->getBody(), $this->eventModel(), $this->format());
        try {
            $this->doProcessEvent($event);
        } catch (OperationNotSupportedException $e) {
            return self::REJECT;
        } catch (OperationFailedException $e) {
            return self::REQUEUE;
        }

        return self::ACK;
    }

    abstract protected function eventModel(): string;

    abstract protected function doProcessEvent(EventInterface $event): void;

    // FYI getSubscribedQueues() is implemented by child classes
}

where getSubscribedQueues() is implemented by child classes. In my project I want to introduce EventProcessorInterface, which can process events data mapped to eventModel() considering getSubscribedEvents(): string[]. But I cannot INJECT EventProcessorInterface to AbstractConsumer and delegate QueueSubscriberInterface::getSubscribedQueues() to EventProcessorInterface::getSubscribedEvents() because it is static method!

andreyserdjuk avatar Apr 20 '22 16:04 andreyserdjuk

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 08:09 stale[bot]