diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm
index d375dfa0d5..1a25c32721 100644
--- a/Koha/BackgroundJob.pm
+++ b/Koha/BackgroundJob.pm
@@ -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;
}
diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in
index d6ebd44498..99abe452a9 100644
--- a/debian/templates/koha-conf-site.xml.in
+++ b/debian/templates/koha-conf-site.xml.in
@@ -441,5 +441,13 @@ __END_SRU_PUBLICSERVER__
__SMTP_DEBUG__
+
+ localhost
+ 61613
+ guest
+ guest
+
+
+
diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml
index c5f827ba8d..118b6b8207 100644
--- a/etc/koha-conf.xml
+++ b/etc/koha-conf.xml
@@ -258,5 +258,13 @@
__SMTP_DEBUG__
+
+ localhost
+ 61613
+ guest
+ guest
+
+
+