Add back headers metadata pass in kafka subscribe (#2281)
* Add back headers metadata pass in kafka subscribe Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com> * Update internal/component/kafka/consumer.go Co-authored-by: Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com> Signed-off-by: Bernd Verst <4535280+berndverst@users.noreply.github.com> Signed-off-by: Deepanshu Agarwal <deepanshu.agarwal1984@gmail.com> Signed-off-by: Bernd Verst <4535280+berndverst@users.noreply.github.com> Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Co-authored-by: Bernd Verst <4535280+berndverst@users.noreply.github.com> Co-authored-by: Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com> Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									c156d4ba04
								
							
						
					
					
						commit
						2582f154bd
					
				|  | @ -188,7 +188,13 @@ func (consumer *consumer) doCallback(session sarama.ConsumerGroupSession, messag | ||||||
| 		Topic: message.Topic, | 		Topic: message.Topic, | ||||||
| 		Data:  message.Value, | 		Data:  message.Value, | ||||||
| 	} | 	} | ||||||
| 
 | 	// This is true only when headers are set (Kafka > 0.11)
 | ||||||
|  | 	if len(message.Headers) > 0 { | ||||||
|  | 		event.Metadata = make(map[string]string, len(message.Headers)) | ||||||
|  | 		for _, header := range message.Headers { | ||||||
|  | 			event.Metadata[string(header.Key)] = string(header.Value) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| 	err = handlerConfig.Handler(session.Context(), &event) | 	err = handlerConfig.Handler(session.Context(), &event) | ||||||
| 	if err == nil { | 	if err == nil { | ||||||
| 		session.MarkMessage(message, "") | 		session.MarkMessage(message, "") | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue