Giter VIP home page Giter VIP logo

rabbitmqbundle's People

Contributors

alexbumbacea avatar andreea-anamaria avatar bastnic avatar bburnichon avatar caciobanu avatar come avatar doppynl avatar fatmuemoo avatar goetas avatar haswalt avatar icolomina avatar igaponov avatar igrizzli avatar ikwattro avatar joelwurtz avatar mihaileu avatar passkey1510 avatar rande avatar richardfullmer avatar ruudk avatar shustrik avatar sixdayz avatar skafandri avatar steveyeah avatar stloyd avatar stof avatar trompette avatar twistedlogic avatar vicb avatar videlalvaro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rabbitmqbundle's Issues

Add symfony recipe

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:

Change CI

Since the project has been forked, we should change the CI to use the project one, not the original one.

Install quality tools

We should install and configure

  • PHP CS Fixer + a pass
  • PHP Stan with at least level 2, and note all the error we could fix.

This would be a first step to make this bundle to evolve :)

PHP8 Compatibility

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?

Unable to get rabbitmq client dependency in controller

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)

Allow symfony 5

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].

Strict Header Binding issue

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:

Screenshot from 2020-08-26 13-33-05

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()

protected function queueDeclare()
{
if ($this->queueOptions['declare']) {
list($queueName, ,) = $this->getChannel()->queue_declare($this->queueOptions['name'], $this->queueOptions['passive'],
$this->queueOptions['durable'], $this->queueOptions['exclusive'],
$this->queueOptions['auto_delete'], $this->queueOptions['nowait'],
$this->queueOptions['arguments'], $this->queueOptions['ticket']);
if (isset($this->queueOptions['routing_keys']) && count($this->queueOptions['routing_keys']) > 0) {
foreach ($this->queueOptions['routing_keys'] as $routingKey) {
$this->queueBind($queueName, $this->exchangeOptions['name'], $routingKey);
}
} else {
$this->queueBind($queueName, $this->exchangeOptions['name'], $this->routingKey);
}
$this->queueDeclared = true;
}
}

protected function queueBind($queue, $exchange, $routing_key)
{
// queue binding is not permitted on the default exchange
if ('' !== $exchange) {
$this->getChannel()->queue_bind($queue, $exchange, $routing_key);
}
}

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:

public function setupFabric()
{
$method = ($this->destinationIsExchange) ? 'exchange_bind' : 'queue_bind';
$channel = $this->getChannel();
call_user_func(
array($channel, $method),
$this->destination,
$this->exchange,
$this->routingKey,
$this->nowait,
$this->arguments
);
}

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:

if (isset($this->queueOptions['routing_keys']) && count($this->queueOptions['routing_keys']) > 0) {
foreach ($this->queueOptions['routing_keys'] as $routingKey) {
$this->queueBind($queueName, $this->exchangeOptions['name'], $routingKey);
}
} else {
$this->queueBind($queueName, $this->exchangeOptions['name'], $this->routingKey);
}

when doing the queueDeclare().

Don't know what you guys think about that, but i would like to read your opinion on that.

thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.