cppkafka icon indicating copy to clipboard operation
cppkafka copied to clipboard

Run-time errors while running consumer function

Open zyercan opened this issue 7 years ago • 4 comments

Hey! I am trying to implement a producer and a consumer functions in cppkafka for windows. The example code for the producer works OK. But I am having problems with the provided consumer code in the examples folder. I set up the zookeeper and kafka servers and ran a producer client in cmd. Even when I implemented a simple code (in MSVS 2015) with basic elements such as

Configuration config = { { "metadata.broker.list", "127.0.0.1:9092" } }; Consumer consumer(config); consumer.subscribe({ "test" });

I am receiving a Debug error when I run the executable (i.e., consumer.exe). It says abort() has been called. Any ideas? Can you provide the simplest consumer code such as the producer one in the readme.md???

zyercan avatar Mar 21 '18 18:03 zyercan

That is really the simplest consumer code. Which exact line is blowing up? Which exception is being thrown?

mfontanini avatar Mar 21 '18 19:03 mfontanini

Any updates on this?

mfontanini avatar Apr 11 '18 03:04 mfontanini

Hey! Sorry for my late response. I had problems with the overloading of << operators while printing to console (such as cout << msg.get_key() and cout << msg.get_payload() << endl;). The build process threw linkage error LNK2019 given as follows: Unresolved external symbol "class std::basic_ostream<char,struct std::char_traits > & __cdecl cppkafka::operator<<(class std::basic_ostream<char,struct std::char_traits > &,class cppkafka::Buffer const &)" (??6cppkafka@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV12@ABVBuffer@0@@Z) referenced in function _main

Anyways I managed to overcome this error by simply writing cout << string(msg.get_payload()); instead of cout << msg.get_payload().

zyercan avatar Apr 11 '18 17:04 zyercan

Ah damn VC. Just fixed that issue, sorry about that.

mfontanini avatar Apr 11 '18 17:04 mfontanini