2013-05-21 63 views
0

我想安裝使用Symfony2.2與RabbitMq bundle簡單AMQP發行商/消費者,我捆頁面錯誤時調用的命令行

出版商正常工作的文檔以下RabbitMQ的消費者,我可以看到我的信息在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 

我的設置:

confi.yml

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 

My \ ApiBundle \服務\ 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 \資源\ 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> 

我的問題是:什麼是錯我的配置或我的代碼?

回答

1

沒有必要註冊你的處理器作爲一項服務 - 徹底刪除My \ ApiBundle \ Resources \ config \ services.xml定義應該解決問題。

+2

也許我做錯了什麼,但是當我從配置中刪除服務定義,我得到錯誤「您已請求不存在服務」 – mmmm

0

我不知道,如果文檔是正確的..但我發現了一個解決方法由OldSound\RabbitMqBundle\RabbitMq\BaseConsumer

所以我的代碼看起來像延伸:

namespace My\ApiBundle\Service; 

use OldSound\RabbitMqBundle\RabbitMq\BaseConsumer; 

class ConsumerService extends BaseConsumer 
{ 

}