Skip to content

Receiving

Robin Harvey edited this page Nov 13, 2011 · 5 revisions

Chapter 4 - A simple message reader

This chapter shows you the simplest way to receive messages from the Amqp broker, using the basic.get method. Using this method, you avoid the complexity involved with setting up a Consumer, but you still get to ack or reject the incoming messages. There's a complete example in the demos.

There's no special way of using this Amqp feature in Amqphp, you just need to create the necessary basic.get objects in the normal way, the response will be returned from Channel->invoke(). Your response will be either basic.get-ok or basic.get-empty, depending on whether any messages were available to read.

Once you've received the message, you have to either ack or reject it. If you ack the message, by sending basic.ack, the broker dequeues the message, but if you send basic.reject the broker will either re-queue or drop the message, depending on the value you put in the basic.reject requeue parameter.

When you send the basic.get, you can set a no-ack parameter which tells the broker to consider all messages delivered via this channel to be acked meaning you don't have to bother sending basic.ack or basic.reject.

Previous Chapter : Sending messages

Next Chapter : Consuming messages

Documentation home

Clone this wiki locally