| 1 |
=head1 NAME |
| 2 |
|
| 3 |
=encoding utf8 |
| 4 |
|
| 5 |
Lemonldap::NG::Common::MessageBroker - Doc for MessageBroker classes |
| 6 |
|
| 7 |
=head1 DESCRIPTION |
| 8 |
|
| 9 |
Starting from 2.20.0, Lemonldap::NG dispatches its events to other nodes using |
| 10 |
L<messages|/"MESSAGE FORMAT"> sent by a I<Lemonldap::NG::Common::MessageBroker> |
| 11 |
sub class. |
| 12 |
|
| 13 |
By default, only 2 kind of L<messages|/"MESSAGE FORMAT"> are dispatched: |
| 14 |
|
| 15 |
=over |
| 16 |
|
| 17 |
=item * B<configuration updates>: each time a configuration is saved. |
| 18 |
|
| 19 |
Note that default broker also adds such messages regularly following the |
| 20 |
C<chectTime> value I<(because it's not a real evant pub/sub system)>. This keep |
| 21 |
previous behavior. |
| 22 |
|
| 23 |
=item * B<session logouts>: whenever a session is terminated before it expires |
| 24 |
I<(either because the user logged out or by action of an administrator)>. |
| 25 |
|
| 26 |
Default broker just push this information on local node. Other will discover |
| 27 |
the end of session after local cache expiration I<(max 10 minutes)>. |
| 28 |
|
| 29 |
=back |
| 30 |
|
| 31 |
By default, LLNG uses only one channel, defined in C<eventQueueName> |
| 32 |
configuration parameter. |
| 33 |
|
| 34 |
During initialization, LLNG creates always 2 distinct objects: |
| 35 |
|
| 36 |
=over |
| 37 |
|
| 38 |
=item * B<a reader> which calls C<subscribe()> for each channel and then check |
| 39 |
for messages every 5 seconds |
| 40 |
|
| 41 |
=item * B<a writer> which send messages on channels |
| 42 |
|
| 43 |
=back |
| 44 |
|
| 45 |
The L<Lemonldap::NG::Hanlder::Main::MsgActions> class contains actions to be |
| 46 |
launched when a message enter in the main events channel. |
| 47 |
|
| 48 |
=head1 METHODS |
| 49 |
|
| 50 |
Except C<applyConf>, all this methods must exist in a Message Broker. |
| 51 |
|
| 52 |
=head2 new |
| 53 |
|
| 54 |
Constructor. Arguments: |
| 55 |
|
| 56 |
=over |
| 57 |
|
| 58 |
=item * B<$class>: class name |
| 59 |
|
| 60 |
=item * B<$conf>: current LLNG configuration |
| 61 |
|
| 62 |
=item * B<$logger>: a Lemonldap::NG::Common logger |
| 63 |
|
| 64 |
=back |
| 65 |
|
| 66 |
=head2 publish |
| 67 |
|
| 68 |
Method to insert an L<message|/"MESSAGE FORMAT">. Arguments: |
| 69 |
|
| 70 |
=over |
| 71 |
|
| 72 |
=item * B<$self> |
| 73 |
|
| 74 |
=item * B<$channel>: the channel name |
| 75 |
|
| 76 |
=item * B<$msg>: a hash reference containing the L<message|/"MESSAGE FORMAT"> |
| 77 |
|
| 78 |
=back |
| 79 |
|
| 80 |
=head2 subscribe |
| 81 |
|
| 82 |
Methode called during LLNG initialization for its message reader object. |
| 83 |
Arguments: |
| 84 |
|
| 85 |
=over |
| 86 |
|
| 87 |
=item * B<$self> |
| 88 |
|
| 89 |
=item * B<$channel>: the channel name |
| 90 |
|
| 91 |
=back |
| 92 |
|
| 93 |
=head2 getNextMessage |
| 94 |
|
| 95 |
Non blocking method that return a L<message|/"MESSAGE FORMAT"> in the given channel if one exists. |
| 96 |
Arguments: |
| 97 |
|
| 98 |
=over |
| 99 |
|
| 100 |
=item * B<$self> |
| 101 |
|
| 102 |
=item * B<$channel>: the channel name |
| 103 |
|
| 104 |
=back |
| 105 |
|
| 106 |
=head2 waitForNextMessage |
| 107 |
|
| 108 |
Blocking method that waits for a L<message|/"MESSAGE FORMAT"> in the given channel and return it. |
| 109 |
Arguments: |
| 110 |
|
| 111 |
=over |
| 112 |
|
| 113 |
=item * B<$self> |
| 114 |
|
| 115 |
=item * B<$channel>: the channel name |
| 116 |
|
| 117 |
=back |
| 118 |
|
| 119 |
=head2 applyConf |
| 120 |
|
| 121 |
Optional method called after configuration save. It is used only with default |
| 122 |
message broker to launch previous behavior: call all "reload URLs". |
| 123 |
|
| 124 |
=head1 MESSAGE FORMAT |
| 125 |
|
| 126 |
A message is a HASH reference. A message in the main event channel must contain |
| 127 |
a key "B<action>". This key is used by |
| 128 |
L<Lemonldap::NG::Hanlder::Main::MsgActions> to launch the corresponding method. |
| 129 |
|
| 130 |
=over |
| 131 |
|
| 132 |
=item * B<Configuration update> |
| 133 |
|
| 134 |
{ |
| 135 |
action => 'newConf' |
| 136 |
} |
| 137 |
|
| 138 |
=item * B<Session end> |
| 139 |
|
| 140 |
{ |
| 141 |
action => 'unlog', |
| 142 |
id => '<configuration id to be removed from local cache>' |
| 143 |
} |
| 144 |
|
| 145 |
=back |
| 146 |
|
| 147 |
=head1 SEE ALSO |
| 148 |
|
| 149 |
L<Lemonldap::NG::Manager>, L<Lemonldap::NG::Portal>, L<Lemonldap::NG::Handler> |
| 150 |
|
| 151 |
=head1 AUTHORS |
| 152 |
|
| 153 |
=over |
| 154 |
|
| 155 |
=item LemonLDAP::NG team L<http://lemonldap-ng.org/team> |
| 156 |
|
| 157 |
=back |
| 158 |
|
| 159 |
=head1 BUG REPORT |
| 160 |
|
| 161 |
Use OW2 system to report bug or ask for features: |
| 162 |
L<https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues> |
| 163 |
|
| 164 |
=head1 DOWNLOAD |
| 165 |
|
| 166 |
Lemonldap::NG is available at |
| 167 |
L<https://lemonldap-ng.org/download> |
| 168 |
|
| 169 |
=head1 COPYRIGHT AND LICENSE |
| 170 |
|
| 171 |
See COPYING file for details. |
| 172 |
|
| 173 |
This library is free software; you can redistribute it and/or modify |
| 174 |
it under the terms of the GNU General Public License as published by |
| 175 |
the Free Software Foundation; either version 2, or (at your option) |
| 176 |
any later version. |
| 177 |
|
| 178 |
This program is distributed in the hope that it will be useful, |
| 179 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 180 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 181 |
GNU General Public License for more details. |
| 182 |
|
| 183 |
You should have received a copy of the GNU General Public License |
| 184 |
along with this program. If not, see L<http://www.gnu.org/licenses/>. |
| 185 |
|
| 186 |
=cut |