0

My application require a list of Records to be published to Kafka topic based on REST API request.

Kafka Stream Binding doc I went throught the document and I cannot find an example of producer only binding.

Is it possble using KafkaStream to publish a list of items on topic without consuming anything?

quintin
  • 812
  • 1
  • 10
  • 35

1 Answers1

0

See https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/spring-cloud-stream.html#_sending_arbitrary_data_to_an_output_e_g_foreign_event_driven_sources

There are cases where the actual source of data may be coming from the external (foreign) system that is not a binder. For example, the source of the data may be a classic REST endpoint. How do we bridge such source with the functional mechanism used by spring-cloud-stream?

Spring Cloud Stream provides two mechanisms, so let’s look at them in more details ...

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • To clarify - Kafka Streams itself cannot only be a producer. This is forwarding data to a Cloud Stream bridge, wrapping a plain Kafka Producer. – OneCricketeer Nov 17 '22 at 13:52
  • 1
    Right; but his link is to the regular spring-cloud-stream Kafka binder, not the KafkaStreams binder - some confusion there with overloaded use of the word "stream(s)" – Gary Russell Nov 17 '22 at 14:11
  • Yeah, I'm looking for producer only support in spring-cloud-stream-binder-kafka. @OneCricketeer so what im asking is not possible? – quintin Nov 17 '22 at 15:21
  • 1
    See the documentation I pointed you to; simply use a `StreamBridge` to send to an output binding. (Or, you can just use a `KafkaTemplate` from spring-kafka. https://spring.io/projects/spring-kafka – Gary Russell Nov 17 '22 at 16:13