| 
									
										
										
										
											2017-04-18 22:20:20 +02:00
										 |  |  | ### Relevant articles
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | - [Intro to Apache Kafka with Spring](http://www.baeldung.com/spring-kafka) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Spring Kafka
 | 
					
						
							| 
									
										
										
										
											2017-03-17 00:04:53 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | This is a simple Spring Boot app to demonstrate sending and receiving of messages in Kafka using spring-kafka. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-24 02:20:30 +05:30
										 |  |  | As Kafka topics are not created automatically by default, this application requires that you create the following topics manually. | 
					
						
							| 
									
										
										
										
											2017-03-17 00:04:53 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-24 02:20:30 +05:30
										 |  |  | `$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic baeldung`<br> | 
					
						
							|  |  |  | `$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 5 --topic partitioned`<br> | 
					
						
							|  |  |  | `$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic filtered`<br> | 
					
						
							|  |  |  | `$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic greeting`<br> | 
					
						
							| 
									
										
										
										
											2017-03-17 00:04:53 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-24 02:20:30 +05:30
										 |  |  | When the application runs successfully, following output is logged on to console (along with spring logs): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### Message received from the 'baeldung' topic by the basic listeners with groups foo and bar
 | 
					
						
							| 
									
										
										
										
											2017-04-18 22:20:20 +02:00
										 |  |  | >Received Message in group 'foo': Hello, World!<br> | 
					
						
							|  |  |  | Received Message in group 'bar': Hello, World! | 
					
						
							| 
									
										
										
										
											2017-03-24 02:20:30 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | #### Message received from the 'baeldung' topic, with the partition info
 | 
					
						
							| 
									
										
										
										
											2017-04-18 22:20:20 +02:00
										 |  |  | >Received Message: Hello, World! from partition: 0 | 
					
						
							| 
									
										
										
										
											2017-03-24 02:20:30 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | #### Message received from the 'partitioned' topic, only from specific partitions
 | 
					
						
							|  |  |  | >Received Message: Hello To Partioned Topic! from partition: 0<br> | 
					
						
							|  |  |  | Received Message: Hello To Partioned Topic! from partition: 3 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### Message received from the 'filtered' topic after filtering
 | 
					
						
							| 
									
										
										
										
											2017-04-18 22:20:20 +02:00
										 |  |  | >Received Message in filtered listener: Hello Baeldung! | 
					
						
							| 
									
										
										
										
											2017-03-24 02:20:30 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | #### Message (Serialized Java Object) received from the 'greeting' topic
 | 
					
						
							| 
									
										
										
										
											2017-04-18 22:20:20 +02:00
										 |  |  | >Received greeting message: Greetings, World!! |