Some new features, cleanups and stability improvements. * Install and use signal handlers in the consumer demo (where available) - this means you can crtl-c a consumer and it will go through the proper shutdown sequence. Some corresponding changes in the EventLoop implementation (forceLoopExit()) * Allow demo script to pick up alternative factory configs via the --config switch * Always set non-blocking mode on all underlying sockets of both types. * Call select() before socket write operations * Track read / writer errors in StreamSocket and make an attempt at matching the error reporting capabilities of low-level socket implementation. * When inside the event loop, deliver messages inside a try / catch, when an exception is caught check to see if the socket has errors, if it does then close the socket / Connection and remove from the event loop. This means that if a socket closes unexpectedly the event loop can recover instead of going in to a tight loop on the select() call.
Mostly a debug release, one important bug fix: * Important bug fix in EventHandler - the parameters to the system select command were wrong and resulted in very high CPU usage. The behaviour of consumers didn't seem to be affected by this issue, it only caused excessive CPU usage (YMMV) * Added support for incoming consumer cancel, this requires API change on the \amqphp\Consumer interface, adding another handler method. This is feature is required before HA queues can be supported. * Update the Channel API so that consume parameters can be specified in an option second parameter to \amqphp\Channel->addConsumer(). The existing \amqphp\Consumer->getConsumeMethod() is still in place, if 2 sets of connection params are available for a single consumer, the Channel prefers the value from getConsumeMethod * Improved the Channel consumer acking behaviour to be easier to use. The Channel keeps a record of the basic.consume params, and skips sending acks for consumers that have specified no-ack=true. Previously, the user had to keep track of whether to return CONSUMER_ACK, CONSUMER_REJECT, etc, this is no longer required as this function is performed inside the Channel * Added an "ack buffer" feature - a new Channel field $ackBuffer can be set to an integer, this causes the Channel to send fewer (n)acks, using the multiple=true flag to ack more than one message at a time. This feature might be useful for busy consumers to reduce network overhead, but care must be taken to ensure that the ackBuffer isn't greater than the basic.qos prefetch-count value, otherwise the Channel goes in to a deadlocked state. I will consider adding code to prevent this in future. * Added client capabilities to the Consumer - this data is sent to RabbitMQ. * Changed the behaviour of the wire protocol code to always use Amqp long strings in Amqp tables, even if the given string could fit inside a small string. This makes dealing with Amqp tables much easier, as RabbitMQ doesn't use short strings (or seems to get upset by them, anyway). Amqp tables can now be specified as normal assoc arrays. * A couple of minor wire message formatting fixes and optimisations. * Lots of new switches for the demo consumer and producer scripts, use --help for more info and usage examples. * Removed all trace of the 'robin' vhost from demo configs. * Platforms-specific tweaks in the forker demo, this is getting a bit long in the tooth now.
Tag release 0.9.2, upgrade from 0.9.1 notes: * Renamed the event loop helper objects from 'SelectHelper' to 'ExitStrategy'. Made analogous renames on consts, i.e. \amqphp\SELECT_COND -> \amqphp\STRAT_COND * Changed the behaviour of a Connection during a select loop - by default, no exit strategy is used!! Note that this is very different to the old behaviour in which, by default, a STRAT_COND (SELECT_COND) strategy is set. If you are upgrading from older versions of Amqphp, add the following code to make Connection behaviour backward compatible: `$connection->pushExitStrategy(\amqphp\STRAT_COND);` * Changed the Connection exit strategy (previously SelectHelper) implementation to allow use of multiple strategies. * Altered channel creation behaviour in \amqphp\Connection, the single getChannel method is replaced by openChannel, getChannel. Backward compat code is in place so that if getChannel is called without any argument (i.e. as per previous behaviour), a warning of type E_USER_DEPRECATED is emitted and the call is diverted to openChannel * Added an optional "Factory" class to assist with creating and configuring connections. Using this component means you can externalise connection configuration (connection parameters and broker setup) in to XML files, the factory will both create connections and run sequences of commands (i.e. broker configuration). Use is optional but recommended. * Added a new API component to handle Channel events - \amqphp\ChannelEventHandler - this replaces the closures set in the Channel->setXXXCallback methods * Simplified and slightly relaxed the \amqphp\wire\Method class, a new public field Method->amqpClass is used to replace lots of getter calls to getClassProto, getMethodProto * Tightened up the behaviour of Channels that receive messages for un-available consumers (i.e. high prefetch count, etc.) - these are now rejected * Added new consumer getter / setter methods, added support for "manually starting a consume session on a broker" so that you're no longer forced to enter an event loop in order to start a consume session on a broker. * Added Channel->toggleFlow() method * Made \amqphp\wire\Method objects serializable. * Removed the API distinction between amqp class and method fields, these are now all accessed through the same getter/setter methods (getField/setField) * Tweaked behaviour of \amqphp\wire\Method wire serialise method to work round issues in current RabbitMQ version (until at least 2.6.1) where protocol invalid fields are returned from the broker. This means that if you specify field values that break the amqp protocol rules, the method will still build, and may trigger errors on the broker. * Implemented Channel and Consumer persistence in the pconnection namespace * Added an APC persistence helper implementation