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

Possibility to get a consumer’s callback #16

Open
dasim opened this issue Mar 9, 2015 · 1 comment
Open

Possibility to get a consumer’s callback #16

dasim opened this issue Mar 9, 2015 · 1 comment
Labels

Comments

@dasim
Copy link

dasim commented Mar 9, 2015

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?

@fprochazka
Copy link
Member

Yeah, I agree. This is good for testing. I had it also in my old codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants