Count message without Ack on a queue

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Count message without Ack on a queue

bloodBaron
Under AMQImpl.Queue.DeclareOk class, getMessageCount() will return the number of messages on a queue.
In java, getMessageCount() doesn't count the messages which haven't receive an Ack yet, but if I use [rabbitmqctl list_queues name messages] in tht terminal, I can see those messages who are consumed by a QueueingConsumer without receiving a ack back.

E.G.,
Assume I've already put 1 message on the queue.

DeclareOk queue= channel.queueDeclare("queue" false, false, true, null);
QueueingConsumer consumer = new QueueingConsumer(channel);
// The server should expect explicit acknowledgements.
channel.basicConsume(queue.getQueue(), false, consumer);

while(true) {
    QueueingConsumer.Delivery delivery = consumer.nextDelivery();
    System.out.println("Received '[" + routingKey + "':'" + message + "]");

    // Do not send an Ack back.
    //channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
   
    queue= channel.queueDeclare("queue" false, false, true, null);
    // System will print 0 here, which means it can't see this message on the queue.
    System.out.println(queue.getMessageCount());
}

If I use "rabbitmqctl list_queues name messages" after I run the above code in terminal, I get the following result:
queue 1
This means rabbitmqctl can count the message which hasn't received an Ack yet.

Is there a way we can use to count the messages without Ack  in Java except by calling rabbitmqctl in Java?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Count message without Ack on a queue

Michael Klishin-4
 On 7 August 2014 at 19:03:45, bloodBaron ([hidden email]) wrote:
> > Is there a way we can use to count the messages without Ack in Java  
> except
> by calling rabbitmqctl in Java?

HTTP API:
http://www.rabbitmq.com/management.html
http://hg.rabbitmq.com/rabbitmq-management/raw-file/rabbitmq_v3_3_4/priv/www/api/index.html
--  
MK  

Staff Software Engineer, Pivotal/RabbitMQ
_______________________________________________
rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
please subscribe to the new list!

[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Count message without Ack on a queue

bloodBaron
The problem about using an HTTP API is the HTTP call is like http://someIP:15672/api/vhosts.
This will leads to a single point failure in a distributed system if someIP goes down.
Even if I use a domain instead of an IP, the system will rely on the domain server, it is NOT a closed system anymore.
Is there a way to communicate with a cluster of RabbitMQ?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Count message without Ack on a queue

Michael Klishin-4
 On 7 August 2014 at 19:23:10, bloodBaron ([hidden email]) wrote:
> > The problem about using an HTTP API is the HTTP call is like
> http://someIP:15672/api/vhosts.
> This will leads to a single point failure in a distributed system  
> if someIP
> goes down.

People run HTTP servers behind load balancers (or even multiple layers of)
at a massive scale at places like Google or Amazon. You could do
the same ;)

> Even if I use a domain instead of an IP, the system will rely on the  
> domain
> server, it is NOT a closed system anymore.

How do you define "closed"? As in security? Then it's up to how you configure
your network. You can use HTTPS with the management plugin, too.

Finally, rabbitmqctl uses distributed Erlang facilities directly, which
means if you can access it and it can connect to the cluster, you can
do *anything*. I'd rather use the HTTP API than try to use rabbitmqctl
directly and then try to make the resulting solution more secure.
--  
MK  

Staff Software Engineer, Pivotal/RabbitMQ
_______________________________________________
rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
please subscribe to the new list!

[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Count message without Ack on a queue

Michael Klishin-4
In reply to this post by Michael Klishin-4
On 7 August 2014 at 19:05:27, Michael Klishin ([hidden email]) wrote:
> > HTTP API:
> http://www.rabbitmq.com/management.html
> http://hg.rabbitmq.com/rabbitmq-management/raw-file/rabbitmq_v3_3_4/priv/www/api/index.html 

… or https://github.com/simonmacmullen/rabbitmq-management-exchange,
which works over AMQP 0-9-1 (so, "regular" RabbitMQ clients).
--  
MK  

Staff Software Engineer, Pivotal/RabbitMQ
_______________________________________________
rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
please subscribe to the new list!

[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Count message without Ack on a queue

bloodBaron
https://github.com/simonmacmullen/rabbitmq-management-exchange
That's exactly what I'm looking for. Thanks a lot!
Loading...