Getting messages is a Synchronous task, which means that is the client who ask to server is there are messages in the queue. You can read an alternative method to Receive Message Aynchronously.
The method GetMessage sends a request to the AMQP server asking if there are messages available in a queue. If there are messages these will be dispatched OnAMQPBasicGetOk event and if the queue is empty, the event OnAMQPBasicGetEmpty will be called.
The method has the following arguments:
AMQP->GetMessage("channel_name", "queue_name");
private void OnAMQPBasicGetOk(TObject *Sender, const string aChannel,
const TsgcAMQPFramePayload_Method_BasicGetOk *aGetOk,
const TsgcAMQPMessageContent *aContent)
{
DoLog("#AMQP_basic_GetOk: " + aChannel + " " + IntToStr(aGetOk->MessageCount) + " " + aContent->Body->AsString);
}
private void OnAMQPBasicGetEmpty(TObject *Sender, const string aChannel)
{
DoLog("#AMQP_basic_GetEmpty: " + aChannel);
}
A Synchronous call can be done just calling the method GetMessageEx, this method returns true if the queue has messages available, otherwise the result will be false.