Skip to content

Possibility to get a consumer’s callback #16

@dasim

Description

@dasim

I have a class (kind of message dealer) that centralises sending messages to rabbit. I’d like to move some part of more complicated calculations to queue but I have a problem to keep my tests as they are, since they expect results of some actions to have effect immediately (since the calculations are sync).

I know I could (and maybe should) change tests to test smaller bits of code that would get around it but I’d find it more practical to just call consumer’s callback synchronously (based on some config). All I need to do that is a way to get a consumer’s callback. So that I can do something like this:

// ... in a method for sending a message
if ($isRabbitDisabled) {
    $consumer = $this->container->getService('rabbitmq.consumer.' . $key);
    $msg = new \PhpAmqpLib\Message\AMQPMessage($encodedData);
    call_user_func($consumer->getCallback());
    return;
}

Do you think adding getCallbackmethod is an option?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions