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

Dynamic transport creation #31373

Closed
DruGity opened this issue May 3, 2019 · 5 comments
Closed

Dynamic transport creation #31373

DruGity opened this issue May 3, 2019 · 5 comments

Comments

@DruGity
Copy link

DruGity commented May 3, 2019

What i need is to create several queues right in code with different names, not in messenger.yaml. I have tried to do it with TransportFactory, but it is not what i need.
So the question is - Can i create queues dynamically? Does such opportunity exists in Messenger component?

@chalasr
Copy link
Member

chalasr commented May 5, 2019

I have tried to do it with TransportFactory, but it is not what i need.

Then can you explain what you mean by "creating queues dynamically"?
If what you want is to create the queue on the transport (doctrine:database:create like) then the SetupableTransportInterface coming in Symfony 4.3 might be the solution.

$transport = $transportFactory->createTransport('dsn');
$transport->setup();

It is implemented by all built-in transports.

@DruGity
Copy link
Author

DruGity commented May 6, 2019

What i need is to create several queues with different names, something like this:

foreach($array as $item) {
    $channel = $bunny->channel();
    $channel->queueDeclare($item['name']); 
}

Like in https://packagist.org/packages/bunny/bunny library
Can i do so in The Messenger Component? Because what i see now - that i can only create one transport with one queue.

@chalasr
Copy link
Member

chalasr commented May 26, 2019

The low-level AmqpFactory seems to be what you are looking for.
Please check the class and its usages to see what you can do with it and tell us if you think there is something more to do in Symfony.
If you need help for experimenting, please try our support platforms and close this issue.
Thank you

@DruGity
Copy link
Author

DruGity commented May 27, 2019

Thanks, you are absolutely right about low-level AmqpFactory. I used another library for my needs. I wish The Messenger had such opportunity, but its great even without it)

@DruGity DruGity closed this as completed May 27, 2019
@oleg-andreyev
Copy link
Contributor

@DruGity Ideally queues are created by consumers, so for each "dynamic" queue you need to create a consumer with correct bindings and publisher just uses AmqpStamp with binding and publish should declare only exchange.

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

No branches or pull requests

4 participants