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.
60 lines
2.3 KiB
60 lines
2.3 KiB
#ifndef __PROTOCOL_KAFKA_HEADER__
|
|
#define __PROTOCOL_KAFKA_HEADER__
|
|
|
|
#ifdef __linux__
|
|
#include <features.h>
|
|
#endif
|
|
|
|
#include <time.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/types.h>
|
|
#include <sys/timeb.h>
|
|
#include <string>
|
|
//#include <librdkafka/rdkafka.h>
|
|
#include <librdkafka/rdkafkacpp.h>
|
|
|
|
#include "protocolEuropeanGeneral.h"
|
|
#include "../../components/base/basicLogCollection.h"
|
|
#include "../../components/base/basicSettingsProvider.h"
|
|
|
|
#ifdef DEBUG
|
|
#define DEBUG_KAFKA
|
|
#endif
|
|
/**
|
|
* TODO: Add class description
|
|
*
|
|
* @author gagua
|
|
*/
|
|
class protocolKAFKA: public RdKafka::DeliveryReportCb, public RdKafka::ConsumeCb, public RdKafka::EventCb{
|
|
private:
|
|
basicLogCollection * m_pLog;
|
|
//config_setting_t * m_pSettings;
|
|
//rd_kafka_t * m_pKafka; /* Producer instance handle */
|
|
RdKafka::Consumer * m_pConsumer;
|
|
RdKafka::Producer * n_pProducer; /* Producer instance handle */
|
|
//rd_kafka_conf_t * m_pKafkaConf; /* Temporary configuration object */
|
|
//RdKafka::Conf * m_pKafkaConf; /* Temporary configuration object */
|
|
//---char m_pKafkaBrokerSTR[OS_CEP_ADDRESS_SIZE];
|
|
//CSTR m_pKafkaTopicSTR;
|
|
//RdKafka::Topic * m_pKafkaTopic;
|
|
KAFKA_SETTINGS * m_pSettings;
|
|
//CSTR m_pServerIP;
|
|
//int m_nServerPort;
|
|
public:
|
|
// Constructor
|
|
explicit protocolKAFKA( KAFKA_SETTINGS *Settings );
|
|
//explicit protocolKAFKA( CSTR ServerAddr, uint16_t Port );
|
|
// Destructor
|
|
virtual ~protocolKAFKA();
|
|
bool init();
|
|
bool issuePost( CSTR Channel, CSTR Buffer, int BufferSize );
|
|
bool receivePost( CSTR Channel, int32_t Partition, int64_t &Offset, CSTR Buffer, int &BufferSize );
|
|
/* Implementation of RdKafka::EventCb */
|
|
virtual void event_cb( RdKafka::Event &event );
|
|
virtual void consume_cb( RdKafka::Message& A, void* B );
|
|
/* Implementation of RdKafka::DeliveryReportCb */
|
|
virtual void dr_cb( RdKafka::Message &message );
|
|
};
|
|
|
|
#endif
|