POE::Component::MessageQueue::Storage::Throttled -- Wraps around another storage engine to throttle the number of messages sent to be stored at one time.
use POE; use POE::Component::MessageQueue; use POE::Component::MessageQueue::Storage::Throttled; use POE::Component::MessageQueue::Storage::DBI; use strict; my $DATA_DIR = '/tmp/perl_mq'; POE::Component::MessageQueue->new({ storage => POE::Component::MessageQueue::Storage::Throttled->new({ storage => POE::Component::MessageQueue::Storage::DBI->new({ dsn => $DB_DSN, username => $DB_USERNAME, password => $DB_PASSWORD, }), throttle_max => 2 }), }); POE::Kernel->run(); exit;
Wraps around another engine to limit the number of messages sent to be stored at once.
Use of this module is highly recommend!
If the storage engine is unable to store the messages fast enough (ie. with slow disk IO) it can get really backed up and stall messages coming out of the queue. This allows a client producing execessive amounts of messages to basically monopolize the server, preventing any messages from getting distributed to subscribers.
It is suggested to keep the throttle_max very low. In an ideal situation, the underlying storage engine would be able to write each message immediately. This means that there will never be more than one message sent to be stored at a time. The purpose of this module is make the message act as though this were the case even if it isn't. So, a throttle_max of 1, will strictly enforce this, however, for a little bit of leniancy, the suggested default is 2.
The storage engine to wrap.
The max number of messages that can be sent to the DBI store at one time.
Ignored. Passed through to the wrapped storage engine.
POE::Component::MessageQueue, POE::Component::MessageQueue::Storage, POE::Component::MessageQueue::Storage::Double
Other storage engines:
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::Complex, POE::Component::MessageQueue::Storage::Default
To install POE::Component::MessageQueue, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::MessageQueue
CPAN shell
perl -MCPAN -e shell install POE::Component::MessageQueue
For more information on module installation, please visit the detailed CPAN module installation guide.