NAME

POE::Component::MessageQueue::Storage::DBI -- A storage backend that uses Perl DBI

SYNOPSIS

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

# For mysql:
my $DB_DSN      = 'DBI:mysql:database=perl_mq';
my $DB_USERNAME = 'perl_mq';
my $DB_PASSWORD = 'perl_mq';
my $DB_OPTIONS  = undef;

POE::Component::MessageQueue->new({
  storage => POE::Component::MessageQueue::Storage::DBI->new({
    dsn      => $DB_DSN,
    username => $DB_USERNAME,
    password => $DB_PASSWORD,
    options  => $DB_OPTIONS
  })
});

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

DESCRIPTION

A storage backend that uses DBI. All messages stored with this backend are persistent.

Rather than using this module directly, I would suggest using POE::Component::MessageQueue::Storage::FileSystem, which uses this module for synchronization but keeps the message body on the filesystem, or POE::Component::MessageQueue::Storage::Complex, which is the overall recommended storage backend.

If you are only going to deal with very small messages then, possibly, you could safely keep the message body in the database. However, this is still not really recommended for a couple of reasons:

  • All database access is conducted through POE::Component::EasyDBI which maintains a single forked process to do database access. So, not only must the message body be communicated to this other proccess via a pipe, but only one database operation can happen at once. The best performance can be achieved by having this forked process do as little as possible.

  • POE::Component::EasyDBI has a limit to the size of queries it will take and query results it will return.

  • A number of database have hard limits on the amount of data that can be stored in a BLOB (namely, SQLite which sets an artificially lower limit than it is actually capable of).

  • Keeping large amounts of BLOB data in a database is bad form anyway! Let the database do what it does best: index and look-up information quickly.

CONSTRUCTOR PARAMETERS

dsn => SCALAR
username => SCALAR
password => SCALAR
options => SCALAR

SEE ALSO

DBI, POE::Component::EasyDBI, POE::Component::MessageQueue, POE::Component::MessageQueue::Storage, POE::Component::MessageQueue::Storage::Memory, POE::Component::MessageQueue::Storage::FileSystem, POE::Component::MessageQueue::Storage::Complex