Skip to content

[amqp] Get message count #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
J7mbo opened this issue Apr 27, 2017 · 5 comments
Closed

[amqp] Get message count #64

J7mbo opened this issue Apr 27, 2017 · 5 comments

Comments

@J7mbo
Copy link
Contributor

J7mbo commented Apr 27, 2017

In AMQPContext::declareQueue(), calling $extQueue->declareQueue() returns an integer which is the message count. But this isn't returned anywhere by the initial method.

Is my only option to override this context with my own, and copy / paste the declareQueue() method code, adding a return for the call through to AMQP::declareQueue()? Can I provide a PR? Or is there another way to get a message count from a queue? Thanks!

@makasim makasim changed the title Get message count [amqp] Get message count Apr 28, 2017
@makasim
Copy link
Member

makasim commented Apr 28, 2017

Can I provide a PR?

Yes sure.

Just out of curiosity what is your usecase? Why do you need a number of messages and how do you use that?

@J7mbo
Copy link
Contributor Author

J7mbo commented Apr 28, 2017

I'm limiting the amount of jobs a given user in my application can add to a queue at any one time. Thanks! Will add a PR soon.

@grekpg
Copy link

grekpg commented May 13, 2019

Im not understatnd, how i can get messages queue - i use symfony bundle. I try


    $factory = new AmqpConnectionFactory('amqp+ext://rabbitmq:rabbitmq@rabit_net:5672/%2f');

        $context = $factory->createContext();

        $fooTopic = $context->createTopic(EnqueueProducer::TOPIC_CREATE_PRODUCT);

        $count = $context->declareTopic($fooTopic);

        $queue = $context->createQueue('aQueue');

        $consumer = $context->createConsumer($fooTopic);

where i can count messages ?

@makasim
Copy link
Member

makasim commented May 13, 2019

$queue = $context->createQueue('aQueue');
$count = $context->declareQueue($queue);

topic (or in terms of rabbitmq -exchange) does not store messages

@grekpg
Copy link

grekpg commented May 13, 2019

$factory = new AmqpConnectionFactory('amqp+ext://rabbitmq:rabbitmq@rabit_net:5672/%2f');

        $context = $factory->createContext();

       $queue = $context->createQueue('enqueue.app.default');

error:

Server channel error: 406, message: PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'enqueue.app.default' in vhost '/': received 'false' but current is 'true'

  $queue = $context->createQueue('enqueue.app.default');

        $queue->setArgument('durable',true);

        $count = $context->declareQueue($queue);

same error.
Can i get queue from some Symfony service ? or how set durable true (this is default settting from symfony) i just need count messages ..

image

For publish i just use constructor

public function __construct(ProducerInterface $producer)

then

$this->producer->sendEvent($topic, $message);

ok i found

$queue->addFlag(AMQP_DURABLE);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants