-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing JSON payload with cppkafka #276
Comments
tested it with a random json parser I found on github and it works fine. If you need further help just drop that file in here also and I can have a look. |
Thank you for getting back to me on this. Which parser did you use? Could you kindly send me a link? I am using the nlohmann JSON parser. Please see the attached json.hpp. |
yeah you're using the library wrong. I'm even surprised it is compiling for you, so I'd suggest you look at your build process and see if something funky is going on. Either way please see below a couple of changes that made your code work for me, and printing out the received events, in json.
And here's a full example where I just removed unnecessary lines for brevity sake:
|
Hi, I am using cppkafka to have a Kafka consumer and connect to a Kafka server. The payload I receive is in a JSON format, so I am looking at converting it to a JSON object and then parse it. However, when I add in the code to create an object, I get the following error:
terminate called after throwing an instance of 'cppkafka::Exception'
what(): Failed to create consumer handle: Failed to create thread: Success (0)
Aborted (core dumped)
If I comment the JSON object creation, the code runs fine and I can read messages from the Kafka server. I am confused as to why the JSON object creation has any relationship to the error.
The code I am using is attached. Lines 20 and 21, when commented, makes the code run fine and the consumer code is able to connect to a Kafka server and read the messages. When I uncomment the lines, I get the error above.
Main.txt.txt
I am thankful to any help in advance!
The text was updated successfully, but these errors were encountered: