/*- * ============LICENSE_START======================================================= * Simulator * ================================================================================ * Copyright (C) 2019 Nokia. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ #include "KafkaWrapper.h" #include #include #include extern "C" { rd_kafka_resp_err_t rd_kafka_last_error (void); rd_kafka_resp_err_t rd_kafka_flush (rd_kafka_t *rk, int timeout_ms); } extern "C" { void kafka_delivery_report_callback(rd_kafka_t *rk, const rd_kafka_message_t *rkmessage, void *opaque) { #ifdef DEBUG if (rkmessage->err) std::cout<<"%% Message delivery failed: %s\n"<err)<len <<" bytes, partition " << rkmessage->partition <<")" << std::endl; /* The rkmessage is destroyed automatically by librdkafka */ #endif } } KafkaWrapper::KafkaWrapper(const char *brokers, const char *topic_name) { this->brokers = brokers; this->topic_name = topic_name; init(); } KafkaWrapper::~KafkaWrapper() { std::cerr<<"%% Flushing final messages..."<