line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright 2007-2010 David Snopek <dsnopek@gmail.com> |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify |
5
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
6
|
|
|
|
|
|
|
# the Free Software Foundation, either version 2 of the License, or |
7
|
|
|
|
|
|
|
# (at your option) any later version. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
10
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12
|
|
|
|
|
|
|
# GNU General Public License for more details. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
15
|
|
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package POE::Component::MessageQueue::Storage::DBI; |
19
|
1
|
|
|
1
|
|
2496
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
extends qw(POE::Component::MessageQueue::Storage::Generic); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has '+package' => ( |
24
|
|
|
|
|
|
|
default => 'POE::Component::MessageQueue::Storage::Generic::DBI', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
around new => sub { |
28
|
|
|
|
|
|
|
my ($original, $class) = (shift, shift); |
29
|
|
|
|
|
|
|
my @args; |
30
|
|
|
|
|
|
|
if (ref($_[0]) eq 'HASH') { |
31
|
|
|
|
|
|
|
@args = %{$_[0]}; |
32
|
|
|
|
|
|
|
} else { |
33
|
|
|
|
|
|
|
@args = @_; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
$original->($class, @args, options => \@args); |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
POE::Component::MessageQueue::Storage::DBI -- A storage engine that uses L<DBI> |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SYNOPSIS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use POE; |
51
|
|
|
|
|
|
|
use POE::Component::MessageQueue; |
52
|
|
|
|
|
|
|
use POE::Component::MessageQueue::Storage::DBI; |
53
|
|
|
|
|
|
|
use strict; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# For mysql: |
56
|
|
|
|
|
|
|
my $DB_DSN = 'DBI:mysql:database=perl_mq'; |
57
|
|
|
|
|
|
|
my $DB_USERNAME = 'perl_mq'; |
58
|
|
|
|
|
|
|
my $DB_PASSWORD = 'perl_mq'; |
59
|
|
|
|
|
|
|
my $DB_OPTIONS = undef; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
POE::Component::MessageQueue->new({ |
62
|
|
|
|
|
|
|
storage => POE::Component::MessageQueue::Storage::DBI->new({ |
63
|
|
|
|
|
|
|
dsn => $DB_DSN, |
64
|
|
|
|
|
|
|
username => $DB_USERNAME, |
65
|
|
|
|
|
|
|
password => $DB_PASSWORD, |
66
|
|
|
|
|
|
|
options => $DB_OPTIONS |
67
|
|
|
|
|
|
|
}) |
68
|
|
|
|
|
|
|
}); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
POE::Kernel->run(); |
71
|
|
|
|
|
|
|
exit; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
A storage engine that uses L<DBI>. All messages stored with this backend are |
76
|
|
|
|
|
|
|
persisted. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Performance is increased greatly by wrapping this engine in |
79
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Throttled> at the expense of being slower |
80
|
|
|
|
|
|
|
to persist messages. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This module is really just L<POE::Component::MessageQueue::Storage::Generic> with |
83
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Generic::DBI>. See the documentation for |
84
|
|
|
|
|
|
|
those modules for more information (primarily |
85
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Generic::DBI>). |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 CONSTRUCTOR PARAMETERS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 2 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item dsn => SCALAR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item username => SCALAR |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item password => SCALAR |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item options => SCALAR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item mq_id => SCALAR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=back |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SEE ALSO |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L<POE::Component::MessageQueue>, |
106
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage>, |
107
|
|
|
|
|
|
|
L<DBI> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
I<Other storage engines:> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Memory>, |
112
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::BigMemory>, |
113
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::FileSystem>, |
114
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Generic>, |
115
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Generic::DBI>, |
116
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Throttled>, |
117
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Complex>, |
118
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Default> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|