Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Data Streaming Applications with Apache Kafka

You're reading from   Building Data Streaming Applications with Apache Kafka Design, develop and streamline applications using Apache Kafka, Storm, Heron and Spark

Arrow left icon
Product type Paperback
Published in Aug 2017
Publisher Packt
ISBN-13 9781787283985
Length 278 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Chanchal Singh Chanchal Singh
Author Profile Icon Chanchal Singh
Chanchal Singh
Manish Kumar Manish Kumar
Author Profile Icon Manish Kumar
Manish Kumar
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Introduction to Messaging Systems FREE CHAPTER 2. Introducing Kafka the Distributed Messaging Platform 3. Deep Dive into Kafka Producers 4. Deep Dive into Kafka Consumers 5. Building Spark Streaming Applications with Kafka 6. Building Storm Applications with Kafka 7. Using Kafka with Confluent Platform 8. Building ETL Pipelines Using Kafka 9. Building Streaming Applications Using Kafka Streams 10. Kafka Cluster Deployment 11. Using Kafka in Big Data Applications 12. Securing Kafka 13. Streaming Application Design Considerations

Java Kafka producer example

We have covered different configurations and APIs in previous sections. Let's start coding one simple Java producer, which will help you create your own Kafka producer.

Prerequisite

  • IDE: We recommend that you use a Scala-supported IDE such as IDEA, NetBeans, or Eclipse. We have used JetBrains IDEA:
    https://www.jetbrains.com/idea/download/.
  • Build tool: Maven, Gradle, or others. We have used Maven to build our project.
  • Pom.xml: Add Kafka dependency to the pom file:
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>0.10.0.0</version>
</dependency>

Java:

import java.util.Properties;
import java.util.concurrent.Future;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime