|
Lines 62-69
Connect to the message broker using default guest/guest credential
Link Here
|
| 62 |
|
62 |
|
| 63 |
sub connect { |
63 |
sub connect { |
| 64 |
my ( $self ); |
64 |
my ( $self ); |
| 65 |
my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } ); |
65 |
my $hostname = 'localhost'; |
| 66 |
$stomp->connect( { login => 'guest', passcode => 'guest' } ); |
66 |
my $port = '61613'; |
|
|
67 |
my $config = C4::Context->config('message_broker'); |
| 68 |
my $credentials = { |
| 69 |
login => 'guest', |
| 70 |
passcode => 'guest', |
| 71 |
}; |
| 72 |
if ($config){ |
| 73 |
$hostname = $config->{hostname} if $config->{hostname}; |
| 74 |
$port = $config->{port} if $config->{port}; |
| 75 |
$credentials->{login} = $config->{username} if $config->{username}; |
| 76 |
$credentials->{passcode} = $config->{password} if $config->{password}; |
| 77 |
$credentials->{host} = $config->{vhost} if $config->{vhost}; |
| 78 |
} |
| 79 |
my $stomp = Net::Stomp->new( { hostname => $hostname, port => $port } ); |
| 80 |
my $frame = $stomp->connect( $credentials ); |
| 81 |
unless ($frame && $frame->command eq 'CONNECTED'){ |
| 82 |
if ($frame){ |
| 83 |
warn $frame->as_string; |
| 84 |
} |
| 85 |
die "Cannot connect to message broker"; |
| 86 |
} |
| 67 |
return $stomp; |
87 |
return $stomp; |
| 68 |
} |
88 |
} |
| 69 |
|
89 |
|