emagtechlabs / rabbitmqbundle Goto Github PK
View Code? Open in Web Editor NEWThis project forked from php-amqplib/rabbitmqbundle
RabbitMQ Bundle for the Symfony web framework
This project forked from php-amqplib/rabbitmqbundle
RabbitMQ Bundle for the Symfony web framework
Update documentation in order to mark version 2 changes.
See original issue https://github.com/php-amqplib/RabbitMqBundle/issues/550
The README still says to use php-amqplib/rabbitmq-bundle
instead of emag-tech-labs/rabbitmq-bundle
Analog to:
Though there is not much to do for a recipe. At least it could create the config old_sound_rabbit_mq
file:
This could include the dotEnv parameters:
# .env
###> php-amqplib/rabbitmq-bundle ###
RABBITMQ_URL=amqp://guest:guest@localhost:5672
RABBITMQ_VHOST=/
###< php-amqplib/rabbitmq-bundle ###
Which could result in:
# config/packages/old_sound_rabbit_mq.yaml
old_sound_rabbit_mq:
connections:
default:
url: '%env(RABBITMQ_URL)%'
vhost: '%env(RABBITMQ_VHOST)%'
Or:
# config/packages/old_sound_rabbit_mq.yaml
parameters:
rabbitmq_url: '%env(RABBITMQ_URL)%'
rabbitmq_vhost: '%env(RABBITMQ_VHOST)%'
old_sound_rabbit_mq:
connections:
default:
url: '%rabbitmq_url%'
vhost: '%rabbitmq_vhost%'
Related:
Since the project has been forked, we should change the CI to use the project one, not the original one.
We should install and configure
This would be a first step to make this bundle to evolve :)
See all the issues mentioned in #11
We are stuck to level 1.
Investigate and try to clean all these issues.
Due to the fact that this bundle is used php-amqplib there is a deprecation message during using the bundle
Example: Required parameter $exchange follows optional parameter $ticket
php-amqplib/php-amqplib#846 - here we can see that php8 support will be not soon and the author does not recommend to use it with php8 at all
Any ideas where to switch for php8 support and how long to wait until this bundle will support php8 without deprecation messages?
Since sf 4.4 it is deprecated: https://github.com/symfony/debug
I tried to follow this example from your documentation:
https://github.com/eMAGTechLabs/RabbitMqBundle#rpc-or-replyresponse
I followed the steps precisely, but when calling controller action, it throws an exception:
Service \"old_sound_rabbit_mq.integer_store_rpc\" not found: even though it exists in the app's container, the container inside \"App\\Controller\\StoreController\" is a smaller service locator that only knows about the \"doctrine\", \"http_kernel\", \"parameter_bag\", \"request_stack\", \"router\", \"security.authorization_checker\", \"security.csrf.token_manager\", \"security.token_storage\", \"serializer\" and \"session\" services. Try using dependency injection instead.
I tried to use dependency injection, but it throws another exception:
Cannot autowire service "App\Controller\MyController": argument "$client" of method "__construct()" references class "OldSound\RabbitMqBundle\RabbitMq\RpcClient" but no such service exists. You should maybe alias this class to the existing "old_sound_rabbit_mq.integer_store_rpc" service.
On both cases, I think it's a bug or the documentation is not clarified well.
Symfony 5.0.7 (env: dev, debug: true)
Hello. Can I install the package on the Symfony 5? When I install as composer require php-amqplib/rabbitmq-bundle, I got
Problem 1 - php-amqplib/rabbitmq-bundle v1.14.4 requires symfony/dependency-injection ^2.7|^3.0|^4.0 -> no matching package found. - php-amqplib/rabbitmq-bundle v1.14.3 requires symfony/dependency-injection ^2.7|^3.0|^4.0 -> no matching package found. - php-amqplib/rabbitmq-bundle v1.14.2 requires symfony/dependency-injection ^2.7|^3.0|^4.0 -> no matching package found. - php-amqplib/rabbitmq-bundle v1.14.1 requires symfony/dependency-injection ^2.7|^3.0|^4.0 -> no matching package found. - php-amqplib/rabbitmq-bundle v1.14.0 requires symfony/dependency-injection ^2.7|^3.0|^4.0 -> no matching package found. - Installation request for php-amqplib/rabbitmq-bundle ^1.14 -> satisfiable by php-amqplib/rabbitmq-bundle[v1.14.0, v1.14.1, v1.14.2, v1.14.3, v1.14.4].
It seems impossible to use a strict headers
exchange routing at the moment.
I basically want to be able to able to bind the queue my-test-queue
to exchange my-test-exchange
only via the header x-test-header: ok
currently i tried this configuration:
producers:
test-producer:
class: My\Custom\Class
connection: default
auto_setup_fabric: false
exchange_options: {name: my-test-exchange, type: headers}
service_alias: producer.test
queue_options:
name: my-test-queue
consumers:
test-consumer:
connection: default
auto_setup_fabric: false
exchange_options: {name: my-test-exchange, type: headers}
callback: consumer.weather_collector
bindings:
- exchange: my-test-exchange
destination: my-test-queue
routing_key: '*'
arguments:
'x-test-header': ['S', ok]
'x-match': ['S', all]
The problem is, even with bindings
option, it will have "two bindings" applied, the first one when configuration of producers
is applied, then the second when the configuration of bindings
is applied.
At the end i got this binding:
The "empty" binding is the problem here, since it allows me to send message to the queue via the exchange without the required header.
Do i miss something here? I tried several configurations without any success. Please let me know if there already has a way to achieve that.
If its not the case, I think there is several solutions to achieve a strict headers binding:
Solution 1:
Allow to pass bind arguments at the queue configuration level.
Currently, we can pass arguments
to queue configuration, but this configuration is not forwarded to the queueBind
method call in BaseAmqp.queueDeclare()
RabbitMqBundle/RabbitMq/BaseAmqp.php
Lines 218 to 236 in d34844a
RabbitMqBundle/RabbitMq/BaseAmqp.php
Lines 245 to 251 in d34844a
that use the AMQPChanel.queue_bind()
(php-amqplib) method, that can handle arguments
public function queue_bind(
$queue,
$exchange,
$routing_key = '',
$nowait = false,
$arguments = array(),
$ticket = null
)
By forwarding the arguments
configuration, we could directly insure a proper binding on the queue configuration level.
Solution 2:
Unbinding empty default binding for source and destination when Binding.setupFabric()
is called. This way, if the developer let the default empty the binding in the queue configuration like in my example:
queue_options:
name: my-test-queue # no binding here, so currently it will automatically bind it to routing_key: ''
It could unbind this automatically between my-test-queue
and my-test-exchange
here:
RabbitMqBundle/RabbitMq/Binding.php
Lines 139 to 151 in d34844a
For example by doing something like that (just an example):
public function setupFabric()
{
$method = ($this->destinationIsExchange) ? 'exchange_bind' : 'queue_bind';
$channel = $this->getChannel();
if ($this->destinationIsExchange) {
$channel->exchange_unbind($this->destination, $this->exchange);
} else {
$channel->queue_unbind($this->destination, $this->exchange);
}
call_user_func(
array($channel, $method),
$this->destination,
$this->exchange,
$this->routingKey,
$this->nowait,
$this->arguments
);
}
Solution 3
Ignoring or overriding the queues declaration bindings for specific queues/exchanges if a bindings
configuration is already set for these queues/exchanges.
Basically, if we set a bindings
configuration that setup a binding between exchange-a
and queue-a
, I don't see the point to also apply the binding here:
RabbitMqBundle/RabbitMq/BaseAmqp.php
Lines 226 to 232 in d34844a
when doing the queueDeclare()
.
Don't know what you guys think about that, but i would like to read your opinion on that.
thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.