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.

63 lines
2.0 KiB

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