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.

59 lines
2.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
4 years ago
​
6 years ago
​
4 years ago
4 years ago
​
​
6 years ago
​
​
4 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. KAFKA_SETTINGS * m_pSettings;
  38. //CSTR m_pServerIP;
  39. //int m_nServerPort;
  40. public:
  41. // Constructor
  42. explicit protocolKAFKA( KAFKA_SETTINGS *Settings );
  43. //explicit protocolKAFKA( CSTR ServerAddr, uint16_t Port );
  44. // Destructor
  45. virtual ~protocolKAFKA();
  46. bool init();
  47. bool issuePost( CSTR Channel, CSTR Buffer, int BufferSize );
  48. bool receivePost( CSTR Channel, int32_t Partition, int64_t &Offset, CSTR Buffer, int &BufferSize );
  49. /* Implementation of RdKafka::EventCb */
  50. virtual void event_cb( RdKafka::Event &event );
  51. virtual void consume_cb( RdKafka::Message& A, void* B );
  52. /* Implementation of RdKafka::DeliveryReportCb */
  53. virtual void dr_cb( RdKafka::Message &message );
  54. };
  55. #endif