I would like to use an Android client as a Kafka Producer. When I try to send a record to the topic I'm getting following error:
Didn't find class "java.lang.management.ManagementFactory
on this line:
mProducer = new KafkaProducer(configProperties);
I am below the limit for the amount of methods:
Total methods in mobile-debug.apk: 52200 (79.65% used)
Total fields in mobile-debug.apk: 21143 (32.26% used)
What can be the reason that causes this error?
By the way, I wasn't able to find any example where kafka producer was used on an Android or iOS.
In addition to the answer of Borys Zibrov, seems that nobody ported it successfully. These threads are also 2 years old.
https://qnalist.com/questions/5017593/has-anybody-successfully-integrated-kafka-jar-for-android-app
https://www.quora.com/In-Apache-Kafka-Can-we-have-mobiles-Android-or-IOS-Devices-as-Consumers-What-is-your-take-on-this
Regarding the ManagementFactory class, see this question: android add java.lang.management API
Apache Kafka is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications.
Yes, if you want to have your producer on Server A and your consumer on server B, you are in the right direction. You need to run a Broker on server A to make it work. The other commands are correct.
I'm actually not sure it's possible to use Kafka as a producer on Android (see for instance, this question, not answered at the moment of writing), because of the dependencies involved. So, someone might have ported Kafka to Android but I don't know that.
I could suggest a simple alternative: REST service that posts data to Kafka, and Android App will just call this service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With