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

[Symfony][RabbitMQ] Enqueue null not working with Enveloppe #60

Open
artandor opened this issue Mar 1, 2019 · 3 comments
Open

[Symfony][RabbitMQ] Enqueue null not working with Enveloppe #60

artandor opened this issue Mar 1, 2019 · 3 comments

Comments

@artandor
Copy link

artandor commented Mar 1, 2019

I followed this documentation because i wanted to test my producer on an API-platform route.

In my case, i want to run my tests in a Gitlab CI environement, which mean there is no real need in testing the connexion to my broker (RabbitMQ here). Therefore, i've followed this configuration :

# app/config/config_test.yml

enqueue:
    default:
        transport: 'null:'
        client: ~

I get an error because the enveloppe is not a supported class of the NullTransport. I need the enveloppe to setup a routing key for rabbitmq.

Uncaught PHP Exception Enqueue\MessengerAdapter\Exception\MissingMessageMetadataSetterException: "Missing "setRoutingKey" setter for "routingKey" metadata key in "Enqueue\Null\NullMessage" class" at /srv/api/vendor/enqueue/messenger-adapter/QueueInteropTransport.php line 220

@weaverryan
Copy link
Collaborator

Hi @artandor!

Ok, so the problem is that you're setting the routingKey in the TransportConfiguration when you're sending one of your messages. This ultimately cases $message->setRoutingKey() to be called. But, when you switch to the null transport, you are switching to the NullMessage(), which does not have a setRoutingKey() method on it. It's tricky: I totally understand what you're trying to do. On the other hand, the library is kind of correct to say: "Hey! You're trying to use an option on your message that is not supported by this transport!".

I'm open to suggestions!

@artandor
Copy link
Author

I guess the AMQP transport configuration lacks of abstraction, which ultimately lead to having a "setRoutingKey" method that is too specific too some transports. It is indeed not really linked to the NullMessage itself. But in the end, the NullMessage becomes buggy when it comes to functionnal testing, which, according to the documentation, was one of its usage.

The simpliest fix could be to add a "dispatch: boolean" in the enqueue conf, that hooks into the dispatch process to stop it before connecting to the amqp server. This way we could use the same DSN instead of enqueue://null and we wouldn't need to bring back the broker online.

@weaverryan
Copy link
Collaborator

The simpliest fix could be to add a "dispatch: boolean" in the enqueue conf, that hooks into the dispatch process to stop it before connecting to the amqp server.

That's an interesting idea. Is that something that's supported in Enqueue in general already? Or are you just thinking out loud. It occurred to me that this is not a problem specific to this library - but Enqueue in general: if you are using the Amqp transport and calling custom setter methods on the AmqpMessage, then if you globally switch to the NullTransport for testing, it would also explode in a very similar way. The best path may be to find out how this is recommended to be handled in Enqueue in general, and then make sure this library is properly supporting that option.

Cheers!

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

2 participants