POE::Component::MessageQueue::Storage::Complex -- A configurable storage engine that keeps a front-store (something fast) and a back-store (something persistent), only storing messages in the back-store after a configurable timeout period.


  use POE;
  use POE::Component::MessageQueue;
  use POE::Component::MessageQueue::Storage::Complex;
  use strict;

    storage => POE::Component::MessageQueue::Storage::Complex->new({
      timeout      => 4,
      granularity  => 2,

      # Only allow the front store to grow to 64Mb
      front_max => 64 * 1024 * 1024,

      front => POE::Component::MessageQueue::Storage::Memory->new(),
      # Or, an alternative memory store is available!
      #front => POE::Component::MessageQueue::Storage::BigMemory->new(),

      back => POE::Component::MessageQueue::Storage::Throttled->new({
        storage => My::Persistent::But::Slow::Datastore->new()

        # Examples include:
        #storage => POE::Component::MessageQueue::Storage::DBI->new({ ... });
        #storage => POE::Component::MessageQueue::Storage::FileSystem->new({ ... });



The idea of having a front store (something quick) and a back store (something persistent) is common and recommended, so this class exists as a helper to implementing that pattern.

The front store acts as a cache who's max size is specified by front_max. All messages that come in are added to the front store. Messages are only removed after having been successfully delivered or when pushed out of the cache by newer messages.

Persistent messages that are not removed after the number of seconds specified by timeout are added to the back store (but not removed from the front store). This optimization allows for the possibility that messages will be handled before having been persisted, reducing the load on the back store.

Non-persistent messages will be discarded when eventually pushed off the front store, unless the expire-after header is specified, in which case they may be stored on the back store inorder to keep around them long enough. Non-persistent messages on the back store which are passed their expiration date will be periodically cleaned up.


timeout => SCALAR

The number of seconds after a message enters the front-store before it expires. After this time, if the message hasn't been removed, it will be moved into the backstore.

granularity => SCALAR

The number of seconds to wait between checks for timeout expiration.

front_max => SCALAR

The maximum number of bytes to allow the front store to grow to. If the front store grows to big, old messages will be "pushed off" to make room for new messages.

front => SCALAR

An optional reference to a storage engine to use as the front store instead of POE::Component::MessageQueue::Storage::BigMemory.

back => SCALAR

Takes a reference to a storage engine to use as the back store.

Using POE::Component::MessageQueue::Storage::Throttled to wrap your main storage engine is highly recommended for the reasons explained in its specific documentation.



Fully supported.


Fully Supported.


Fully Supported.


POE::Component::MessageQueue::Storage::Complex::Default - The most common case. Based on this storage engine.

POE::Component::MessageQueue, POE::Component::MessageQueue::Storage, POE::Component::MessageQueue::Storage::Double

Other storage engines:

POE::Component::MessageQueue::Storage::Default, POE::Component::MessageQueue::Storage::Memory, POE::Component::MessageQueue::Storage::BigMemory, POE::Component::MessageQueue::Storage::FileSystem, POE::Component::MessageQueue::Storage::DBI, POE::Component::MessageQueue::Storage::Generic, POE::Component::MessageQueue::Storage::Generic::DBI, POE::Component::MessageQueue::Storage::Throttled POE::Component::MessageQueue::Storage::Default