title: How to retrieve multiple message in RabbitMQ callback?
body: <p>I am using a rabbitmq in symfony framework to publish and consume the queue data. I successfully push the data into queue but while reading the data i'm having a issue. single message i can read easily but problem with the multiple message with callback.</p>
  
  <p>I have create a design for consuming the queue using some service.</p>
  
  <p>QueueService.php</p>
  
  <pre><code>class QueueService
  {
  protected $logger;
  public function addInQueue($class, $data, $event,$isEnabled)
  {
      $publishData = $this-&gt;getPublishData($class, $data, $event,$isEnabled);
      $this-&gt;queue-&gt;publish($publishData);
  }
  
  public function fetchInQueue()
  {
      $this-&gt;logger-&gt;info(' fetchInQueue &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;');
      $res = $this-&gt;queue-&gt;consume();
      $this-&gt;logger-&gt;info('received message &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;'.print_r($res,true));
  }
  }
  </code></pre>
  
  <p>AMQPHelper.php</p>
  
  <pre><code>class AMQPHelper {
  
  protected $conConfig;
  protected $queueConfig;
  protected $logger;
  private $response;
  
  public function __construct($conConfig, $queueConfig)
  {
      $this-&gt;conConfig = $conConfig;
      $this-&gt;queueConfig = $queueConfig;
      $loggerHelper = new LoggerHelper();
      $this-&gt;logger = $loggerHelper-&gt;init('amqp-helper');
  }
  public function consume()
  {
  
      $connection = new AMQPConnection(
          $this-&gt;conConfig['host'],
          $this-&gt;conConfig['port'],
          $this-&gt;conConfig['username'],
          $this-&gt;conConfig['password'],
          $this-&gt;conConfig['vhost']
      );
      $channel = $connection-&gt;channel();
  
  
      $channel-&gt;exchange_declare(
          $this-&gt;queueConfig['exchange'],
          'direct',
          false,
          true,
          false
      );
      $channel-&gt;queue_declare(
          $this-&gt;queueConfig['exchange'],
          false,
          true,
          false,
          false
      );
      $channel-&gt;queue_bind(
          $this-&gt;queueConfig['exchange'],
          $this-&gt;queueConfig['exchange'],
          $this-&gt;queueConfig['routing']
      );
  
      //Consume
      $channel-&gt;basic_qos(null, 1, null);
      $channel-&gt;basic_consume(
          $this-&gt;queueConfig['exchange'],
          $this-&gt;queueConfig['routing'],
          false,
          false,
          false,
          false,
          array($this,'getQueueMsg')
      );
  
      while(count($channel-&gt;callbacks)) {
          $this-&gt;logger-&gt;info('  messages'.print_r($this-&gt;response,1));
          $this-&gt;logger-&gt;info('Waiting for incoming messages');
          $channel-&gt;wait();
      }
  
      $connection-&gt;close();
      $channel-&gt;close();
  
      return $this-&gt;response;
  }
  
  public function getQueueMsg(AMQPMessage $msg)
  {
      $this-&gt;logger-&gt;info('Message body', print_r($msg, 1));
      $data = json_decode($msg-&gt;body, true);
      $this-&gt;response = $data;
  }
  </code></pre>
  
  <p>I have write a console command to use QueueService function.I want all the queue return data in console command because after getting all queue data i want to re-run some console commands based on data.</p>
  
  <p>ConsumeFailureCommand.php</p>
  
  <pre><code>class ConsumeFailureCommand extends BaseCommand{
  
  protected function configure()
  {
      $this
          -&gt;setName('consume-failure')
          -&gt;setDescription('notification message consumer from RabbitMQ')
          -&gt;addOption(
              'wait',
              null,
              InputOption::VALUE_REQUIRED,
              'Wait for next message',
              1
          );
  }
  
  protected function execute(InputInterface $input, OutputInterface $output){
      $queueMng = $this-&gt;getContainer()-&gt;get('service_queue_management.queue_service');
      $this-&gt;setInput($input);
      $this-&gt;setOutput($output);
      $data = $queueMng-&gt;fetchInQueue();
      $this-&gt;logInfo(print_r($data,1));
  }
  </code></pre>
  
  <p>}</p>
  
  <p>so how the queue will return all data to service. It will return single message everytime but i want multidimension array of all data.</p>