I've used RabbitMQ server and for publishing messages when the immediate field was set true ,I tried sending 50,000 messages and using rabbitmqctl list_queues, I saw that number of messages in the queue was zero. Then I changed the immediate flag to false and again tried sending 50,000 messages and then using rabbitmqctl list_queues i saw that total 100,000 messages were in queues.(Till now no consumer was present)

And after that I started consumer and it consumed all the 100,000 messages.Can anybody please help me in understanding about immediate bit field and this behavior too. Also, I could not understand the concept of mandatory bit field.

This flag tells the server how to
react if a message cannot be routed to
a queue. Specifically, if mandatory is
set and after running the bindings the
message was placed on zero queues then
the message is returned to the sender
(with a basic.return). If mandatory
had not been set under the same
circumstances the server would
silently drop the message.

Or in my words, "Put this message on at least one queue. If you can't, send it back to me."

For a message published with immediate
set, if a matching queue has ready
consumers then one of them will have
the message routed to it. If the lucky
consumer crashes before ack'ing
receipt the message will be requeued
and/or delivered to other consumers on
that queue (if there's no crash the
messaged is ack'ed and it's all done
as per normal). If, however, a
matching queue has zero ready
consumers the message will not be
enqueued for subsequent redelivery on
from that queue. Only if all of the
matching queues have no ready
consumers that the message is returned
to the sender (via basic.return).

Or in my words, "If there is at least one consumer connected to my queue that can take delivery of a message right this moment, deliver this message to them immediately. If there are no consumers connected then there's no point in having my message consumed later and they'll never see it. They snooze, they lose."

What happens if the lucky consumer crashes before acking the receipt and there are no other consumers on the queue? Does the message still just sit in the queue? Or does it get returned?
–
nornagonApr 28 '14 at 22:45