How to check whether Kafka Server is running?

后端 未结 9 1564
无人及你
无人及你 2020-12-08 03:46

I want to ensure whether kafka server is running or not before starting production and consumption jobs. It is in windows environment and here\'s my kafka server\'s code in

9条回答
  •  难免孤独
    2020-12-08 04:39

    I found an event OnError in confluent Kafka:

    consumer.OnError += Consumer_OnError;
    
     private void Consumer_OnError(object sender, Error e)
        {
            Debug.Log("connection error: "+ e.Reason);
            ConsumerConnectionError(e);
        }
    

    And its documentation in code:

        //
        // Summary:
        //     Raised on critical errors, e.g. connection failures or all brokers down. Note
        //     that the client will try to automatically recover from errors - these errors
        //     should be seen as informational rather than catastrophic
        //
        // Remarks:
        //     Executes on the same thread as every other Consumer event handler (except OnLog
        //     which may be called from an arbitrary thread).
        public event EventHandler OnError;
    

提交回复
热议问题