如何使用Android App作为“生产客户端"卡夫卡? [英] How to use Android App as a "Producing client" for Kafka?

查看:57
本文介绍了如何使用Android App作为“生产客户端"卡夫卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Android 应用程序作为 Apache Kafka 的生产客户端"是否可能/是否有意义?

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

假设我的 Android 应用需要捕获和分析反应时间数据.目标是收集所有数据并在应用中实时显示平均反应时间.

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.

另一种方法是使用某种应用服务器作为接受来自 android 应用程序的消息并将它们发布到的中介Kafka,而不是让应用自己成为 Kafka Producer.

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.

推荐答案

即使有可能,在我看来它也有一些缺点.

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

总的来说,我喜欢客户端尽可能简单以避免维护问题.相反,我会通过我的应用服务器上的 REST API 路由所有客户端请求.缺点与Kafka无关,是原生客户端的通病.

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.

耦合

您正在将 Android 应用与您的消息传递基础架构紧密结合.如果您后来认为 Kafka 解决方案太多,而普通的旧 Java 就足够了,那么您首先必须更新 Android 应用并等待足够多的用户进行更新.

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.

网络问题 + 交付保证

Kafka 客户端还需要与每个代理直接连接.移动客户端的网络连接可能非常不一致/不稳定,这使得直接客户端访问容易受到掉线事件和整体网络连接问题的影响.

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.

身份验证

可能您的应用中已经有某种身份验证.您还可以创建经过身份验证的到 Kafka 的连接.因此,您将有两个身份验证路径,而对于应用服务器,Kafka 只需要检查请求是否来自受信任的应用服务器,这意味着更少的实现工作.

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.

...

这篇关于如何使用Android App作为“生产客户端"卡夫卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆