You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
2.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
6 years ago
​
6 years ago
​
​
​
​
6 years ago
​
​
6 years ago
​
​
​
​
​
6 years ago
​
​
​
  1. #ifndef __PROTOCOL_KAFKA_HEADER__
  2. #define __PROTOCOL_KAFKA_HEADER__
  3. #ifdef __linux__
  4. #include <features.h>
  5. #endif
  6. #include <time.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <sys/types.h>
  10. #include <sys/timeb.h>
  11. #include <string>
  12. //#include <librdkafka/rdkafka.h>
  13. #include <librdkafka/rdkafkacpp.h>
  14. #include "protocolEuropeanGeneral.h"
  15. #include "../../components/base/basicLogCollection.h"
  16. #include "../../components/base/basicSettingsProvider.h"
  17. /**
  18. * TODO: Add class description
  19. *
  20. * @author gagua
  21. */
  22. class protocolKAFKA: public RdKafka::DeliveryReportCb, public RdKafka::ConsumeCb, public RdKafka::EventCb{
  23. private:
  24. basicLogCollection * m_pLog;
  25. //config_setting_t * m_pSettings;
  26. //rd_kafka_t * m_pKafka; /* Producer instance handle */
  27. RdKafka::Consumer * m_pConsumer;
  28. RdKafka::Producer * n_pProducer; /* Producer instance handle */
  29. //rd_kafka_conf_t * m_pKafkaConf; /* Temporary configuration object */
  30. //RdKafka::Conf * m_pKafkaConf; /* Temporary configuration object */
  31. char m_pKafkaBrokerSTR[OS_CEP_ADDRESS_SIZE];
  32. //CSTR m_pKafkaTopicSTR;
  33. //RdKafka::Topic * m_pKafkaTopic;
  34. CSTR m_pServerIP;
  35. int m_nServerPort;
  36. public:
  37. // Constructor
  38. explicit protocolKAFKA( KAFKA_SETTINGS *Settings );
  39. explicit protocolKAFKA( CSTR ServerAddr, uint16_t Port );
  40. // Destructor
  41. virtual ~protocolKAFKA();
  42. bool init();
  43. bool issuePost( CSTR Channel, CSTR Buffer, int BufferSize );
  44. bool receivePost( CSTR Channel, int32_t Partition, int64_t Offset, CSTR Buffer, int &BufferSize );
  45. /* Implementation of RdKafka::EventCb */
  46. virtual void event_cb( RdKafka::Event &event );
  47. virtual void consume_cb( RdKafka::Message& A, void* B );
  48. /* Implementation of RdKafka::DeliveryReportCb */
  49. virtual void dr_cb( RdKafka::Message &message );
  50. };
  51. #endif