Book Image

Apache Kafka

By : Nishant Garg
Book Image

Apache Kafka

By: Nishant Garg

Overview of this book

<p>Message publishing is a mechanism of connecting heterogeneous applications together with messages that are routed between them, for example by using a message broker like Apache Kafka. Such solutions deal with real-time volumes of information and route it to multiple consumers without letting information producers know who the final consumers are.</p> <p>Apache Kafka is a practical, hands-on guide providing you with a series of step-by-step practical implementations, which will help you take advantage of the real power behind Kafka, and give you a strong grounding for using it in your publisher-subscriber based architectures.</p> <p>Apache Kafka takes you through a number of clear, practical implementations that will help you to take advantage of the power of Apache Kafka, quickly and painlessly. You will learn everything you need to know for setting up Kafka clusters. This book explains how Kafka basic blocks like producers, brokers, and consumers actually work and fit together. You will then explore additional settings and configuration changes to achieve ever more complex goals. Finally you will learn how Kafka works with other tools like Hadoop, Storm, and so on.</p> <p>You will learn everything you need to know to work with Apache Kafka in the right format, as well as how to leverage its power of handling hundreds of megabytes of messages per second from multiple clients.</p>
Table of Contents (15 chapters)

Preface

This book is here to help you get familiar with Apache Kafka and use it to solve your challenges related to the consumption of millions of messages in publisher-subscriber architecture. It is aimed at getting you started with a feel for programming with Kafka so that you will have a solid foundation to dive deep into its different types of implementations and integrations.

In addition to an explanation of Apache Kafka, we also offer a chapter exploring Kafka integration with other technologies such as Apache Hadoop and Storm. Our goal is to give you an understanding of not just what Apache Kafka is, but also how to use it as part of your broader technical infrastructure.

What this book covers

Chapter 1, Introducing Kafka, discusses how organizations are realizing the real value of data and evolving the mechanism of collecting and processing it.

Chapter 2, Installing Kafka, describes how to install and build Kafka 0.7.x and 0.8.

Chapter 3, Setting up the Kafka Cluster, describes the steps required to set up a single/multibroker Kafka cluster.

Chapter 4, Kafka Design, discusses the design concepts used for building a solid foundation for Kafka.

Chapter 5, Writing Producers, provides detailed information about how to write basic producers and some advanced-level Java producers that use message partitioning.

Chapter 6, Writing Consumers, provides detailed information about how to write basic consumers and some advanced-level Java consumers that consume messages from the partitions.

Chapter 7, Kafka Integrations, discusses how Kafka integration works for both Storm and Hadoop to address real-time and batch processing needs.

Chapter 8, Kafka Tools, describes information about Kafka tools, such as its administrator tools, and Kafka integration with Camus, Apache Camel, Amazon cloud, and so on.

What you need for this book

In the simplest case, a single Linux-based (CentOS 6.x) machine with JDK 1.6 installed will give you a platform to explore almost all the exercises in this book. We assume you have some familiarity with command-line Linux; any modern distribution will suffice.

Some of the examples in this book need multiple machines to see things working, so you will require access to at least three such hosts. Virtual machines are fine for learning and exploration.

You will generally need the big data technologies, such as Hadoop and Storm, to run your Hadoop and Storm clusters.

Who this book is for

This book is for readers who want to know about Apache Kafka at a hands-on level; the key audience is those with software development experience but no prior exposure to Apache Kafka or similar technologies.

This book is also for enterprise application developers and big data enthusiasts who have worked with other publisher-subscriber-based systems and now want to explore Apache Kafka as a futuristic scalable solution.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

String messageStr = new String("Hello from Java Producer");
KeyedMessage<Integer, String> data = new KeyedMessage<Integer, String>(topic, messageStr);
producer.send(data);

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

Properties props = new Properties();
props.put("metadata.broker.list","localhost:9092");
props.put("serializer.class","kafka.serializer.StringEncoder");
props.put("request.required.acks", "1");
ProducerConfig config = new ProducerConfig(props); 
Producer<Integer, String> producer = new Producer<Integer, String>(config);

Any command-line input or output is written as follows:

[root@localhost kafka-0.8]# java SimpleProducer kafkatopic Hello_There

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots used in this book. You can download this file from http://www.packtpub.com/sites/default/files/downloads/7938OS_Images.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.