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.

58 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. #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. private:
  27. basicLogCollection * m_pLog;
  28. //config_setting_t * m_pSettings;
  29. //rd_kafka_t * m_pKafka; /* Producer instance handle */
  30. RdKafka::Consumer * m_pConsumer;
  31. RdKafka::Producer * n_pProducer; /* Producer instance handle */
  32. //rd_kafka_conf_t * m_pKafkaConf; /* Temporary configuration object */
  33. //RdKafka::Conf * m_pKafkaConf; /* Temporary configuration object */
  34. char m_pKafkaBrokerSTR[OS_CEP_ADDRESS_SIZE];
  35. //CSTR m_pKafkaTopicSTR;
  36. //RdKafka::Topic * m_pKafkaTopic;
  37. CSTR m_pServerIP;
  38. int m_nServerPort;
  39. public:
  40. // Constructor
  41. explicit protocolKAFKA( KAFKA_SETTINGS *Settings );
  42. explicit protocolKAFKA( CSTR ServerAddr, uint16_t Port );
  43. // Destructor
  44. virtual ~protocolKAFKA();
  45. bool init();
  46. bool issuePost( CSTR Channel, CSTR Buffer, int BufferSize );
  47. bool receivePost( CSTR Channel, int32_t Partition, int64_t &Offset, CSTR Buffer, int &BufferSize );
  48. /* Implementation of RdKafka::EventCb */
  49. virtual void event_cb( RdKafka::Event &event );
  50. virtual void consume_cb( RdKafka::Message& A, void* B );
  51. /* Implementation of RdKafka::DeliveryReportCb */
  52. virtual void dr_cb( RdKafka::Message &message );
  53. };
  54. #endif