Difference between kafka and nifi

BERGUIGA Mohamed Amine picture BERGUIGA Mohamed Amine · Nov 29, 2018 · Viewed 11.4k times · Source

I'm a beginner with Apache NiFi, but until now All the tutorial that I read speak about the integration of kafka with Nifi. how it kafka is the complementary of Nifi? why we don't use Nifi directly to pusblish our message without the using of kafka?

Note: All tutorial that I seen does not speak about this point.

Answer

Sivaprasanna Sethuraman picture Sivaprasanna Sethuraman · Nov 29, 2018

NiFi and Kafka complements in the sense that NiFi is not a messaging queue like Apache Kafka. On the contrary, Apache NiFi is a data-flow management aka data logistics tool.

Let's assume this scenario: You have messages (in JSON format) getting streamed through Kafka and you want to validate the messages to check if the message has all the fields and if they are valid, you want the messages to land in HBase.

Here NiFi can help you with the following approach:

  • NiFi has ConsumeKafka processors which you can configure with your Kafka broker and the group name.
  • Use the NiFi processor ValidateRecord to check if the received messages are all valid
  • If they are valid, you can connect the output to PutHBaseRecord

Summarizing, NiFi basically prevents you from writing a lot of boilerplate code. In this case, a custom logic to do schema validation and writing to HBase.