= Apache Kafka Publisher (Consumer function)

A `Consumer<Message<?>>` that allows to publish messages to Apache Kafka topic.


== Beans for injection

The `KafkaPublisherConfiguration` is an auto-configuration, so no need to import anything.

The `Consumer<Message<?>> kafkaPublisher` bean can be injected into the target service for producing data into Kafka topic.

== Configuration Options

All configuration properties are prefixed with `kafka.publisher`.

For more information on the various options available, please see link:src/main/java/org/springframework/cloud/fn/consumer/kafka/KafkaPublisherProperties.java[KafkaPublisherProperties].
Also, this artifact fully depends on Spring for Apache Kafka auto-configuration and injects a `KafkaTemplate` from there.

A `ComponentCustomizer<KafkaProducerMessageHandlerSpec<?, ?, ?>>` bean can be added in the target project to provide any custom options for the `KafkaProducerMessageHandlerSpec` configuration used by the `kafkaPublisher`.

The `KafkaPublisherConfiguration` also exposes 3 `PublishSubscribeChannel`: `kafkaPublisherSuccessChannel`, `kafkaPublisherFailureChannel`, `kafkaPublisherFuturesChannel`.
They are mapped to respective options of the `KafkaProducerMessageHandler`.
They may be subscribed in the target project any possible Spring Integration way.
See more information about `KafkaProducerMessageHandler` configuration and behavior in Spring Integration https://docs.spring.io/spring-integration/docs/current/reference/html/kafka.html=kafka-outbound[documentation].

== Other usage

See this https://github.com/spring-cloud/stream-applications/blob/master/applications/sink/kafka-sink/README.adoc[README] where this consumer is used to create a Spring Cloud Stream application where it makes an Apache Kafka sink.
