Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Android App as a "Producing client" for Kafka?

Is it possible / does it make sense to use an Android app as a "Producing client" for Apache Kafka?

Let's say my Android App need to capture and analyse reaction time data. Goal is to collect all data and show the average reaction time in real-time in the App.

The alternative is having an app server of some kind as an intermediary that accepts messages from the android app and posts them to Kafka, rather than having the app be a Kafka Producer on its own.

like image 978
lidox Avatar asked Oct 14 '16 12:10

lidox


People also ask

Can Android connect to Kafka?

Don't go through the pain of direct integration. RudderStack's Android SDK makes it easy to send data from your Android app to Apache Kafka ...and all of your other cloud tools.

Is Kafka producer an API?

KafkaProducer API Let us understand the most important set of Kafka producer API in this section. The central part of the KafkaProducer API is KafkaProducer class. The KafkaProducer class provides an option to connect a Kafka broker in its constructor with the following methods.

What is the producer client in Kafka?

Kafka producer client consists of the following API’s. Let us understand the most important set of Kafka producer API in this section. The central part of the KafkaProducer API is KafkaProducer class. The KafkaProducer class provides an option to connect a Kafka broker in its constructor with the following methods.

What is the kafkaproducer API?

Let us understand the most important set of Kafka producer API in this section. The central part of the KafkaProducer API is KafkaProducer class. The KafkaProducer class provides an option to connect a Kafka broker in its constructor with the following methods.

What is Kafka protocol and how it works?

The Kafka protocol is fairly simple, there are only six core client requests APIs. Metadata - Describes the currently available brokers, their host and port information, and gives information about which broker hosts which partitions. Send - Send messages to a broker

How to create a Kafka application using ZooKeeper and Kafka broker?

Before creating the application, first start ZooKeeper and Kafka broker then create your own topic in Kafka broker using create topic command. After that create a java class named Sim-pleProducer.java and type in the following coding. Compilation − The application can be compiled using the following command.


2 Answers

Even if it's possible, in my opinion it has some disadvantages.

In general I like clients to be as simple as possible to avoid maintenance issues. Instead I'd route all client requests through a REST API on my app server. The disadvantages are not related to Kafka, but are common problems of native clients.

Coupling

You're coupling the Android app closely to your messaging infrastructure. If you later decide that a Kafka solution is too much and Plain Old Java would be good enough, you'll first have to update the Android app and wait until enough users do an update.

Network issues + delivery guarantees

Kafka clients also require a direct connection to each of the brokers. Mobile clients can have very inconsistent/spotty network connectivity, making direct client access susceptible to dropped events and overall network connectivity issues.

Authentication

Probably you already have some kind of authentication in your app. You can also create authenticated connections to Kafka. So you'll have two authentication paths, whereas with an app server Kafka only needs to check if the requests are coming from the trusted app server, which means less implementation effort.

...

like image 153
Christian Strempfer Avatar answered Nov 06 '22 22:11

Christian Strempfer


I think it would make lots of sense:

  • Kafka-clients.jar provide auto-reconnecting capability which is very useful when the phone is on a flaky internet connection
  • The Kafka-clients.jar is quite thin and does not include any of Kafka Server code (it doesn't even depend on Scala).

Unfortunately, it isn't compatible with Android just now: KAFKA-7025 . If you'd like to see this happen, please upvote the JIRA issue.

like image 38
Martin Vysny Avatar answered Nov 06 '22 23:11

Martin Vysny