Skip to content

Upgrading

BraveSirRobin edited this page Mar 3, 2012 · 11 revisions

Upgrade notes for Amqphp, all versions.

Version 0.9.5 - March 2012

  • Changes to the publish confirms feature:
  1. Channel will now save a copy of each outgoing message when in confirm mode, this could have RAM usage implications for processes that publish large numbers of messages
  2. When confirm (n)acks are received, the Channel delivers the actual message that is being confirmed to the ChannelEventHandler. Previously, the Channel would deliver the incoming ack to the CEH, which is pretty useless because the only information held in the ack is the message sequence number (which is internal to the Channel) and because the broker often sends acks with multiple=true, which means the channel delivers the same incoming ack message many times.
  1. Only specify the multiple=true flag on (n)acks if the $ackBuffer value is > 1. This means that you can do "out of order" acking, whereby you return CONSUMER_* responses intermingled with NULL responses, and the CONSUMER_* responses won't implicitly ack the messages for which the Consumer returned NULL. Note that if you do this, it's your responsibility to ack or reject the messages that your consumer returned NULL for, if you don't do this then you'll end up losing messages, or having messages re-delivered to other consumers
  • Fixes and cleanups in the low-level socket code - make the 2 implementations more alike, ensure that all sockets are in non-blocking mode and use select() to do blocking reads / writes.
  • Stability fixes to better handle unexpected socket closure
  • Some more features for the demo scripts

Version 0.9.4

  • 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.

Version 0.9.3 - December 2011

  • Bug fix release, nothing new or interesting.

Version 0.9.2 - November 2011.

  • 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

Version 0.9.1, July 2011

This was a pre-release version containing an initial implementation of persistent connections, do not use this version.

Version 0.9, May 2011.

New features / Changes

  1. Changed the root namespace from amqp_091 to amqphp. The auto-load-able branch uses this namespace already. A couple of reasons for this change; firstly the underscore in the root namespace could confuse some older PHP5.2 based class loaders which use the underscore as a package delimiter, secondly this is a better name - the root namespace now identifies the library in use (amqp_091 was too generic).

  2. Removed the event loop functionality from the \amqphp\Connection class in placed this in a separate class, \amqphp\EventLoop. The reason for this is that Amqphp now supports multiple broker connections - you can create connections to 2 or more brokers and consume from both at the same time. Note that the Connection->select() method is still in place, it uses the new implementation too.

  3. Moved the SELECT_* consts out of the \amqphp\Connection class and made them stand-alone consts. This was done because these consts are now used by more than one implementation class.

  4. Changed the timeout based EventLoop exist strategies so that the second parameter passed to Connection->setSelectMode() is an integer (microseconds) rather than a fraction. This is to simplify the timeout calculations, and to be more consistent with the php socket_select() and stream_select() functions.

Suggestions on how to upgrade

Here are some suggestions on how to handle the above changes in your code.

  1. This is pretty much a search and replace job. In most cases you should be able to change the namespace alias at the top of your code files from amqp_091 to amqphp. For info, here's the commit where I made this change. If this change causes you issues and you're using Linux you might try using sed to do the replace for you, something along the lines of this may help: sed -i 's/amqp_091/amqphp/' 'find . -name '*.php'' [NOTE: that sed command should have backticks around find . -name '*.php' - I can't do this here because it clashes with the Github Wiki syntax!]

  2. These changes should be backwards compatible - let me know if this one causes you problems. This is the most important new feature in the 0.9 release, you now have the ability to consume from more than one Amqp broker at the same time, using an "asynchronous" processing model.

  3. This change should also be backwards compatible as the class-level consts are still in place. I expect to remove these for version 1.0

  4. This one changes the way that you specify timeouts for event loops, here's an equivalent before and after sample:

Before

$conn->setSelectMode(amqp\SELECT_TIMEOUT_REL, 1, 0.5);

After

$conn->setSelectMode(amqp\SELECT_TIMEOUT_REL, 1, 500000);

The third parameter is a microseconds figure (1 millionth of a second).