2017-07-03 22:35:47 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								<!-- 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								   Licensed to the Apache Software Foundation (ASF) under one or more
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   contributor license agreements.  See the NOTICE file distributed with
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   this work for additional information regarding copyright ownership.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   The ASF licenses this file to You under the Apache License, Version 2.0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   (the "License"); you may not use this file except in compliance with
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   the License.  You may obtain a copy of the License at
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      http://www.apache.org/licenses/LICENSE-2.0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   Unless required by applicable law or agreed to in writing, software
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   distributed under the License is distributed on an "AS IS" BASIS,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   See the License for the specific language governing permissions and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   limitations under the License.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								   -->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  <!-- #include virtual="../js/templateData.js"  --> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / script > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-28 05:20:29 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								< style > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 .video__item{cursor:pointer;}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / style > 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-03 22:35:47 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< script  id = "streams-template"  type = "text/x-handlebars-template" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-22 03:15:54 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  < h1 > Kafka Streams< / h1 > 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-09 03:43:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    < div  class = "sub-nav-sticky" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        < div  class = "sticky-top" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            < div  style = "height:35px" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < a  class = "active-menu-item"  href = "/{{version}}/documentation/streams/" > Introduction< / a > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                < a  href = "/{{version}}/documentation/streams/quickstart" > Run Demo App< / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < a  href = "/{{version}}/documentation/streams/tutorial" > Tutorial: Write App< / a > 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 08:28:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                < a  href = "/{{version}}/documentation/streams/core-concepts" > Concepts< / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < a  href = "/{{version}}/documentation/streams/architecture" > Architecture< / a > 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-09 03:43:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                < a  href = "/{{version}}/documentation/streams/developer-guide/" > Developer Guide< / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < a  href = "/{{version}}/documentation/streams/upgrade-guide" > Upgrade< / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < h3  class = "streams_intro" > The easiest way to write mission-critical real-time applications and microservices< / h3 > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								       < p  class = "streams__description" > Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								       < div  class = "video__series__grid" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          < div  class = "yt__video__block" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            < div  class = "yt__video__inner__block" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < iframe   class = "yt_series video_1 active"  style = "display:block"  src = "https://www.youtube.com/embed/Z3JKCLG3VP4?rel=0&showinfo=0&end=602"  frameborder = "0"  allowfullscreen > < / iframe > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < iframe   class = "yt_series video_2"  src = "https://www.youtube.com/embed/LxxeXI1mPKo?rel=0&showinfo=0&end=622"  frameborder = "0"  allowfullscreen > < / iframe > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < iframe   class = "yt_series video_3"  src = "https://www.youtube.com/embed/7JYEEx7SBuE?rel=0&showinfo=0end=557"  frameborder = "0"  allowfullscreen > < / iframe > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < iframe   class = "yt_series video_4"  src = "https://www.youtube.com/embed/3kJgYIkAeHs?rel=0&showinfo=0&end=564"  frameborder = "0"  allowfullscreen > < / iframe > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            < div  class = "video__block" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < h3 > TOUR OF THE STREAMS API< / h3 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < div  class = "video__list" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   < p  class = "video__item video_list_1 active"  onclick = "$('.video__item').removeClass('active'); $(this).addClass('active');$('.yt_series').hide();$('.video_1').show();" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                       < span  class = "number" > 1< / span > < span  class = "video__text" > Intro to Streams< / span > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   < / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   < p  class = "video__item video_list_2"  onclick = "$('.video__item').removeClass('active'); $(this).addClass('active');$('.yt_series').hide();$('.video_2').show();" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                       < span  class = "number" > 2< / span > < span  class = "video__text" > Creating a Streams Application< / span > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   < / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   < p  class = "video__item video_list_3"  onclick = "$('.video__item').removeClass('active'); $(this).addClass('active');$('.yt_series').hide();$('.video_3').show();" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                       < span  class = "number" > 3< / span > < span  class = "video__text" > Transforming Data Pt. 1< / span > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   < / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   < p  class = "video__item video_list_4"  onclick = "$('.video__item').removeClass('active'); $(this).addClass('active');$('.yt_series').hide();$('.video_4').show();" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                      < span  class = "number" > 4< / span > < span  class = "video__text" > Transforming Data Pt. 11< / span > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   < / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								       < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								       < hr  class = "separator" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								       < div  class = "use-item-section" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < div  class = "use__list__sec" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < h3 > Why you'll love using Kafka Streams!< / h3 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < ul  class = "use-feature-list" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                  < li > Elastic, highly scalable, fault-tolerant< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                  < li > Deploy to containers, VMs, bare metal, cloud< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                  < li > Equally viable for small, medium, &  large use cases< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                  < li > Fully integrated with Kafka security< / li > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                  < li > Write standard Java and Scala applications< / li > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                  < li > Exactly-once processing semantics< / li > 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-17 02:30:11 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                  < li > No separate processing cluster required< / li > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                  < li > Develop on Mac, Linux, Windows< / li > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               < / ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < div  class = "first__app__cta" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < a  href = "/{{version}}/documentation/streams/tutorial"  class = "first__app__btn" > Write your first app< / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								       < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								       < hr  class = "separator"  id = "streams-use-cases" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 08:28:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        < h3  class = "stream__text" > Kafka Streams use cases< / h3 > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								         < div  class = "customers__grid" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < div  class = "customer__grid" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             < div  class = "customer__item streams_logo_grid streams__ny__grid" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               < a  href = "https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077"  target = "_blank"  class = "grid__logo__link" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                 < span  class = "grid__item__logo"  style = "background-image: url('/images/powered-by/NYT.jpg');" > < / span > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < / a > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               < p  class = "grid__item__customer__description extra__space" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 08:28:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                 < a  href = "https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077"  target = "_blank" > The New York Times uses Apache Kafka < / a > and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               < / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < div  class = "customer__grid" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             < div  class = "customer__item  streams_logo_grid streams__zalando__grid" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < a  href = "https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/"  target = "_blank"  class = "grid__logo__link" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                 < span  class = "grid__item__logo"  style = "background-image: url('/images/powered-by/zalando.jpg');" > < / span > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < p  class = "grid__item__customer__description extra__space" > As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                 < a  href = "https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/"  target = 'blank' >  event streams< / a >  enables our technical team to do near-real time business intelligence.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < div  class = "customer__grid" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             < div  class = "customer__item  streams_logo_grid streams__line__grid" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               < a  href = "https://engineering.linecorp.com/en/blog/detail/80"  target = "_blank"  class = "grid__logo__link" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                 < span  class = "grid__item__logo"  style = "background-image: url('/images/powered-by/line.svg');width:9rem" > < / span > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < / a > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                 < p  class = "grid__item__customer__description extra__space" > < a  href = "https://engineering.linecorp.com/en/blog/detail/80"  target = "_blank" > LINE uses Apache Kafka< / a >  as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated yet minimal code base.< / p > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								             < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < div  class = "customer__grid" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								             < div  class = "customer__item streams_logo_grid streams__ny__grid" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < a  href = "https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996"  target = "_blank"  class = "grid__logo__link" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                 < span  class = "grid__item__logo"  style = "background-image: url('/images/powered-by/pinterest.png');" > < / span > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               < / a > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               < p  class = "grid__item__customer__description" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 08:28:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   < a  href = "https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996"  target = "_blank" > Pinterest uses Apache Kafka and the Kafka Streams< / a >  at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               < / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < div  class = "customer__grid" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             < div  class = "customer__item  streams_logo_grid streams__rabobank__grid" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               < a  href = "https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/"  target = "_blank"  class = "grid__logo__link" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                 < span  class = "grid__item__logo"  style = "background-image: url('/images/powered-by/rabobank.jpg');" > < / span > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < / a > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                 < p  class = "grid__item__customer__description" > Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is < a  href = "https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/"  target = "_blank" > built using Kafka Streams.< / a > < / p > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								             < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < div  class = "customer__grid" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             < div  class = "customer__item streams_logo_grid streams__ny__grid" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < a  href = "https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition"  target = "_blank"  class = "grid__logo__link" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                 < span  class = "grid__item__logo"  style = "background-image: url('/images/powered-by/trivago.png');" > < / span > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < p  class = "grid__item__customer__description" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to < a  href = "https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition"  target = "_blank" > enable our developers< / a >  to access data freely in the company. Kafka Streams powers parts of our analytics pipeline and delivers endless options to explore and operate on the data sources we have at hand.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-01 04:22:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								       < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								       < h3  style = "margin-top: 5.3rem;" > Hello Kafka Streams< / h3 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								       < p > The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale< / p > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								       < div  class = "code-example" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < div  class = "btn-group" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < a  class = "selected b-java-8"  data-section = "java-8" > Java 8+< / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < a  class = "b-java-7"  data-section = "java-7" > Java 7< / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < a  class = "b-scala"  data-section = "scala" > Scala< / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < div  class = "code-example__snippet b-java-8 selected" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < pre  class = "brush: java;" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.common.serialization.Serdes;
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.common.utils.Bytes;
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.KafkaStreams;
							 
						 
					
						
							
								
									
										
										
										
											2017-11-03 23:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.StreamsBuilder;
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.StreamsConfig;
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.kstream.KStream;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.kstream.KTable;
							 
						 
					
						
							
								
									
										
										
										
											2017-11-03 23:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.kstream.Materialized;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.kstream.Produced;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.state.KeyValueStore;
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import java.util.Arrays;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import java.util.Properties;
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   public class WordCountApplication {
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                       public static void main(final String[] args) throws Exception {
							 
						 
					
						
							
								
									
										
										
										
											2018-06-05 04:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                           Properties props = new Properties();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-03 23:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                           StreamsBuilder builder = new StreamsBuilder();
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                           KStream< String, String>  textLines = builder.stream("TextLinesTopic");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           KTable< String, Long>  wordCounts = textLines
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                               .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\\W+")))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                               .groupBy((key, word) -> word)
							 
						 
					
						
							
								
									
										
										
										
											2017-11-03 23:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                               .count(Materialized.< String, Long, KeyValueStore< Bytes, byte[]> > as("counts-store"));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-05 04:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                           KafkaStreams streams = new KafkaStreams(builder.build(), props);
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                           streams.start();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                       }
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < / pre > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < div  class = "code-example__snippet b-java-7" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < pre  class = "brush: java;" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.common.serialization.Serdes;
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.common.utils.Bytes;
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.KafkaStreams;
							 
						 
					
						
							
								
									
										
										
										
											2017-11-03 23:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.StreamsBuilder;
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.StreamsConfig;
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.kstream.KStream;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.kstream.KTable;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.kstream.ValueMapper;
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.kstream.KeyValueMapper;
							 
						 
					
						
							
								
									
										
										
										
											2017-11-03 23:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.kstream.Materialized;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.kstream.Produced;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import org.apache.kafka.streams.state.KeyValueStore;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   import java.util.Arrays;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   import java.util.Properties;
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   public class WordCountApplication {
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                       public static void main(final String[] args) throws Exception {
							 
						 
					
						
							
								
									
										
										
										
											2018-06-05 04:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                           Properties props = new Properties();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-03 23:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                           StreamsBuilder builder = new StreamsBuilder();
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                           KStream< String, String>  textLines = builder.stream("TextLinesTopic");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           KTable< String, Long>  wordCounts = textLines
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                               .flatMapValues(new ValueMapper< String, Iterable< String> > () {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                                   @Override
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                                   public Iterable< String>  apply(String textLine) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                                       return Arrays.asList(textLine.toLowerCase().split("\\W+"));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                                   }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                               })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                               .groupBy(new KeyValueMapper< String, String, String> () {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                                   @Override
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                                   public String apply(String key, String word) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                                       return word;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                                   }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                               })
							 
						 
					
						
							
								
									
										
										
										
											2017-11-03 23:51:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                               .count(Materialized.< String, Long, KeyValueStore< Bytes, byte[]> > as("counts-store"));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                           wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-05 04:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                           KafkaStreams streams = new KafkaStreams(builder.build(), props);
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                           streams.start();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                       }
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                   }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < / pre > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < div  class = "code-example__snippet b-scala" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               < pre  class = "brush: scala;" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import java.util.Properties
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import java.util.concurrent.TimeUnit
							 
						 
					
						
							
								
									
										
										
										
											2018-02-09 01:53:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import org.apache.kafka.streams.kstream.Materialized
							 
						 
					
						
							
								
									
										
										
										
											2018-05-07 11:55:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import org.apache.kafka.streams.scala.ImplicitConversions._
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import org.apache.kafka.streams.scala._
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import org.apache.kafka.streams.scala.kstream._
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								object WordCountApplication extends App {
							 
						 
					
						
							
								
									
										
										
										
											2018-05-09 00:15:31 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  import Serdes._
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-05 04:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  val props: Properties = {
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    val p = new Properties()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    p
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-07 11:55:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  val builder: StreamsBuilder = new StreamsBuilder
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  val wordCounts: KTable[String, Long] = textLines
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    .flatMapValues(textLine => textLine.toLowerCase.split("\\W+"))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    .groupBy((_, word) => word)
							 
						 
					
						
							
								
									
										
										
										
											2019-04-01 23:39:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    .count()(Materialized.as("counts-store"))
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  wordCounts.toStream.to("WordsWithCountsTopic")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-05 04:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  streams.start()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  sys.ShutdownHookThread {
							 
						 
					
						
							
								
									
										
										
										
											2018-05-07 11:55:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								     streams.close(10, TimeUnit.SECONDS)
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               < / pre > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								       < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								       < div  class = "pagination" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-09 03:43:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < a  href = "/{{version}}/documentation"  class = "pagination__btn pagination__btn__prev" > Previous< / a > 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 08:28:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           < a  href = "/{{version}}/documentation/streams/quickstart"  class = "pagination__btn pagination__btn__next" > Next< / a > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								       < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-07-03 22:35:47 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< / script > 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-07 22:10:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								<!-- #include virtual="../../includes/_header.htm"  --> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								<!-- #include virtual="../../includes/_top.htm"  --> 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-03 22:35:47 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< div  class = "content documentation documentation--current" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  <!-- #include virtual="../../includes/_nav.htm"  --> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < div  class = "right" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    <!-- #include virtual="../../includes/_docs_banner.htm"  --> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < ul  class = "breadcrumbs" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      < li > < a  href = "/documentation" > Documentation< / a > 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-22 03:15:54 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      < li > < a  href = "/documentation/streams" > Kafka Streams< / a > < / li > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      < / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < / ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < div  class = "p-streams" > < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-03 22:35:47 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< / div > 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-07 22:10:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								<!-- #include virtual="../../includes/_footer.htm"  --> 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-03 22:35:47 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< script > 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  $(function() {
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								         // Show selected style on nav item
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         $('.b-nav__streams').addClass('selected');
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         $('.video_list_1').click(function(){
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								             $('.video_2').attr('src', $('.video_2').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             $('.video_3').attr('src', $('.video_3').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             $('.video_4').attr('src', $('.video_4').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								         $('.video_list_2').click(function(){
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               $('.video_1').attr('src', $('.video_1').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               $('.video_3').attr('src', $('.video_3').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               $('.video_4').attr('src', $('.video_4').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								         $('.video_list_3').click(function(){
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								              $('.video_1').attr('src', $('.video_1').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								              $('.video_2').attr('src', $('.video_2').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								              $('.video_4').attr('src', $('.video_4').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								         $('.video_list_4').click(function(){
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								              $('.video_1').attr('src', $('.video_1').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								              $('.video_2').attr('src', $('.video_2').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								              $('.video_3').attr('src', $('.video_3').attr('src'));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           });
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          //sticky secondary nav
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          var $navbar = $(".sub-nav-sticky"),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               y_pos = $navbar.offset().top,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               height = $navbar.height();
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								           $(window).scroll(function() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               var scrollTop = $(window).scrollTop();
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								               if (scrollTop > y_pos - height) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   $navbar.addClass("navbar-fixed")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               } else if (scrollTop < = y_pos) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                   $navbar.removeClass("navbar-fixed")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           });
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 06:16:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								         // Display docs subnav items
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         $('.b-nav__docs').parent().toggleClass('nav__item__with__subs--expanded');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         // Show selected code example
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         $('.btn-group a').click(function(){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             var targetClass = '.b-' + $(this).data().section;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             $('.code-example__snippet, .btn-group a').removeClass('selected');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             $(targetClass).addClass('selected');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								       });
							 
						 
					
						
							
								
									
										
										
										
											2018-04-24 04:33:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								< / script >