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.
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);
// Do not send an Ack back.
queue= channel.queueDeclare("queue" false, false, true, null);
// System will print 0 here, which means it can't see this message on the queue.
If I use "rabbitmqctl list_queues name messages" after I run the above code in terminal, I get the following result:
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?
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?
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
> 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
> 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.