swarrot / SwarrotBundle

A symfony bundle for swarrot integration
MIT License
89 stars 59 forks source link

Switch getChannel to public #98

Closed j0k3r closed 7 years ago

j0k3r commented 7 years ago

This will fix https://github.com/swarrot/SwarrotBundle/issues/97

But more globally it'll allow anyone to retrieve the channel of a RabbitMQ connection using the swarrot.factory.default service (if you defined the provider as amqp_lib) and then do whatever you want with it (like retrieve a message, etc.).

For example you can retrieve one message (without ack'ing it) to retrieve the total messages in a queue:

$message = $this
    ->get('swarrot.factory.default')
    ->getChannel('rabbitmq') // returns a PhpAmqpLib\Channel\AMQPChannel
    ->basic_get('queue_name'); // returns a PhpAmqpLib\Message\AMQPMessage

var_dump($message->delivery_info['message_count']);
odolbeau commented 7 years ago

:+1: