Skip to content
Robin Harvey edited this page Sep 24, 2011 · 19 revisions

#Amqphp API overview

This section introduces the key API components of the Amqphp library and explains their usage. Note that Amqphp is written using namespaces (the root namespace is \amqphp)

Main API classes

  • \amqphp\Connection. Represents a connection to a single Amqp broker, contains the underlying TCP resource and a variable number of Amqp Channels.
  • \amqphp\Channel. Represents an Amqp channel, these objects are created by calling \amqphp\Connection->openChannel() and are stored in the Connection thereafter. The Channel class uses the PHP __call method as a factory for creating Amqp messages, and has an invoke method that sends messages to the broker.
  • \amqphp\Factory. A helper class which can be used to externalise broker and client configuration. Amqp clients must configure the broker using Amqp methods, and this class provides a means of externalising this configuration.
  • \amqphp\Method. An object that contains a single Amqp message, whether incoming (received from broker) or outgoing (to be sent to broker). A pretty simple class with getField / setField / getContent / setContent being the most commonly used functions.
  • \amqphp\Consumer. An interface that defines operations for a consumer callback class. Objects of this interface are the end point for messages that are delivered to Amqp consumer application.
  • \amqphp\EventLoop. Implements consumer routines that listen for incoming messages. The basic behaviour is to block and wait for incoming messages indefinitely, this behaviour can be tweaked by setting an exit strategy
Clone this wiki locally