我正在尝试使用带有RabbitMq 捆绑包的 Symfony2.2 设置一个简单的 AMQP 发布者/消费者,我正在关注捆绑包页面上的文档
发布者工作正常,我可以在rabbitMq 的网络管理器上看到我的消息。当我尝试使用命令运行消费者时
php app/console rabbitmq:consumer my.api
我收到以下错误:
Call to undefined method My\ApiBundle\Service\ConsumerService::setRoutingKey() in /***/vendor/oldsound/rabbitmq-bundle/OldSound/RabbitMqBundle/Command/BaseConsumerCommand.php on line 91
我的设置:
配置文件
old_sound_rabbit_mq:
connections:
my.api:
host: %amqp_host%
port: %amqp_port%
user: %amqp_user%
password: %amqp_password%
vhost: %amqp_vhost%
producers:
my.api:
connection: my.api
exchange_options: {name: 'my.api', type: fanout}
consumers:
my.api:
connection: my.api
exchange_options: {name: 'my.api', type: fanout}
queue_options: {name: 'my.api'}
callback: my.api
我的\ApiBundle\Service\ConsumerService.php
namespace My\ApiBundle\Service;
use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface;
class ConsumerService implements ConsumerInterface
{
public function execute(\PhpAmqpLib\Message\AMQPMessage $msg)
{
return false;
}
}
我的\ApiBundle\Resources\config\services.xml
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="old_sound_rabbit_mq.my.api_consumer" class="My\ApiBundle\Service\ConsumerService"></service>
</services>
</container>
我的问题是:我的配置或代码有什么问题?