NAME

POE::Component::MessageQueue::Storage::Complex -- A storage backend that keeps messages in memory but moves them into persistent storage after a given number of seconds.

SYNOPSIS

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

my $DATA_DIR = '/tmp/perl_mq';

POE::Component::MessageQueue->new({
  storage => POE::Component::MessageQueue::Storage::Complex->new({
    data_dir => $DATA_DIR,
    timeout  => 2
  })
});

POE::Kernel->run();
exit;

DESCRIPTION

This storage backend combines two other provided backends. It uses POE::Component::MessageQueue::Storage::Memory as the "front-end storage" and POE::Component::MessageQueue::Storage::FileSystem as the "back-end storage". Message are initially put into the front-end storage and will be moved into the backend storage after a given number of seconds.

The POE::Component::MessageQueue::Storage::FileSystem component used internally is configured to use DBD::SQLite. Based on my experience this is the most efficient way to use it.

This storage backend is recommended. It should provide the best performance while (if configured sanely) still providing a reasonable amount of persistence with little risk of eating all your memory under high load. This is also the only storage backend to correctly honor the persistent flag and will only persist those messages with it set.

CONSTRUCTOR PARAMETERS

data_dir => SCALAR

The directory to store the SQLite database file and the message body's.

timeout => SCALAR

The number of seconds a message will remain in non-persistent storage. Ie. After this many seconds if the message hasn't been removed, it will be put to persistent storage.

SEE ALSO

DBI, DBD::SQLite, POE::Component::MessageQueue, POE::Component::MessageQueue::Storage, POE::Component::MessageQueue::Storage::Memory, POE::Component::MessageQueue::Storage::FileSystem, POE::Component::MessageQueue::Storage::DBI