Kafka icon indicating copy to clipboard operation
Kafka copied to clipboard

Unable to detect broker status when creating connection object

Open SunYour opened this issue 8 years ago • 0 comments

I'm trying to find a way how to monitor the status of the connection object. If I shut down my Kafka broker, the response message is still the same as when it is up and running.

                 '_IO_cache' => {
                                  'cau:29092' => {
                                                   'NodeId' => undef,
                                                   'IO' => undef,
                                                   'port' => '29092',
                                                   'host' => 'cau'
                                                 }
                                },
                 '_metadata' => {},
                 'MaxLoggedErrors' => 100,
                 'dont_load_supported_api_versions' => 0,
                 'AutoCreateTopicsEnable' => 0,
                 'ip_version' => undef,
                 'broker_list' => [],
                 '_group_coordinators' => {},
                 'SEND_MAX_ATTEMPTS' => 4,
                 'port' => 29092,
                 'host' => 'cau',
                 '_nonfatal_errors' => [],
                 '_leaders' => {},
                 'timeout' => '1.5',
                 'RETRY_BACKOFF' => 200
               }, 'Kafka::Connection' );

I expect to get some kind of error.

Also, both hashes for cluster errors and non fatal errors are empty.

$VAR1 = {};

Non fatal errors:
$VAR1 = [];

The only way (?) to detect an error is currently by, for example call get_metadata and it will throw an exception

Cannot get metadata: topic='<undef>' (same thing happens if I define an exisiting topic)

Trace begun at /opt/app/xxx/xxx-perl/xxx-perllib/lib/perl5/Kafka/Connection.pm line 1592
Kafka::Connection::_error('Kafka::Connection=HASH(0x1d1aa90)', -1007, 'topic=\'<undef>\'') called at /opt/app/xxx/xxx-perl/xxx-perllib/lib/perl5/Kafka/Connection.pm line 693
Kafka::Connection::get_metadata('Kafka::Connection=HASH(0x1d1aa90)') called at /opt/app/xxx/xxx-perl/xxx-perllib/lib/perl5/Xxx/Kafka/Connector.pm line 79
Xxx::Kafka::Connector::__ANON__ at /opt/app/xxx/xxx-perl/xxx-perllib/lib/perl5/Try/Tiny.pm line 81
eval {...} at /opt/app/xxx/xxx-perl/xxx-perllib/lib/perl5/Try/Tiny.pm line 72
Try::Tiny::try('CODE(0x1d1ae98)', 'Try::Tiny::Catch=REF(0xa00448)') called at /opt/app/xxx/xxx-perl/xxx-perllib/lib/perl5/Xxx/Kafka/Connector.pm line 83

Connection is created using $connection = Kafka::Connection->new(host => $hostname, port => $port);

Am I missing something? Thanks

SunYour avatar Oct 17 '17 08:10 SunYour