Bug 26742: Add configuration to koha-conf.xml for message broker

The connection details for the message broker should be configurable.
This patch adds configuration options to koha-conf.xml. If they
are not specified, then default connection details will be used.

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
David Cook 2020-10-20 11:54:46 +11:00 committed by Jonathan Druart
parent 75a210aef4
commit 8663f23a93
3 changed files with 38 additions and 2 deletions

View file

@ -62,8 +62,28 @@ Connect to the message broker using default guest/guest credential
sub connect {
my ( $self );
my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
$stomp->connect( { login => 'guest', passcode => 'guest' } );
my $hostname = 'localhost';
my $port = '61613';
my $config = C4::Context->config('message_broker');
my $credentials = {
login => 'guest',
passcode => 'guest',
};
if ($config){
$hostname = $config->{hostname} if $config->{hostname};
$port = $config->{port} if $config->{port};
$credentials->{login} = $config->{username} if $config->{username};
$credentials->{passcode} = $config->{password} if $config->{password};
$credentials->{host} = $config->{vhost} if $config->{vhost};
}
my $stomp = Net::Stomp->new( { hostname => $hostname, port => $port } );
my $frame = $stomp->connect( $credentials );
unless ($frame && $frame->command eq 'CONNECTED'){
if ($frame){
warn $frame->as_string;
}
die "Cannot connect to message broker";
}
return $stomp;
}

View file

@ -441,5 +441,13 @@ __END_SRU_PUBLICSERVER__
<debug>__SMTP_DEBUG__</debug>
</smtp_server>
<message_broker>
<hostname>localhost</hostname>
<port>61613</port>
<username>guest</username>
<password>guest</password>
<vhost></vhost>
</message_broker>
</config>
</yazgfs>

View file

@ -258,5 +258,13 @@
<debug>__SMTP_DEBUG__</debug>
</smtp_server>
<message_broker>
<hostname>localhost</hostname>
<port>61613</port>
<username>guest</username>
<password>guest</password>
<vhost></vhost>
</message_broker>
</config>
</yazgfs>