
AMQP 1.x API
------------
The following is an overview of using the AMQP API.


The AMQP communication layer
----------------------------
AMQP provides a centralized set of API functions for publishing and consuming
messages from an AMQP-compatible message queue server:

    // Publish a durable, direct message to exchange [foo], routing key [bar.baz]:
    amqp_publish('foo', 'bar.baz', t('Message body goes here.'), AMQP_DURABLE, AMQP_EX_TYPE_DIRECT, $arguments);


Adding an AMQP consumer
-----------------------
In order to define an AMQP consumer, follow these steps:
    
1. Implement hook_amqp_consumers() to define your callback function, exchange,
route, queue name, and other arguments. Please note the parameters below (with
the exception of 'callback') should match your specific message queue setup.

        function mymodule_amqp_consumers() {
          $consumers = array(
            array(
              'callback' => 'mymodule_consumer_dosomething',
              'exchange' => 'mymodule',
              'routing_key' => 'mymodule.do.something',
              'queue_name' => 'mymodule_queue',
              'arguments' => array(),
              'flags' => AMQP_DURABLE,
              'type' => AMQP_EX_TYPE_DIRECT
            )
          );
          return $consumers;
        }

2. Write your consumer callback function. This will be called when there is a message received from the AMQP server on the defined parameters in hook_amqp_consumer().

        function mymodule_consumer_dosomething($message) {
          // Now that you have the message, you can do something with it.
        }


