Skip to content

Instantly share code, notes, and snippets.

@pradeekpmohandas
Created August 1, 2020 17:38
Show Gist options
  • Select an option

  • Save pradeekpmohandas/13f44af3930ab37f781595402c71be11 to your computer and use it in GitHub Desktop.

Select an option

Save pradeekpmohandas/13f44af3930ab37f781595402c71be11 to your computer and use it in GitHub Desktop.

Revisions

  1. pradeekpmohandas created this gist Aug 1, 2020.
    17 changes: 17 additions & 0 deletions Producer-Kafka.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    @Configuration
    public class Producer {

    @Autowired
    private KafkaTemplate<String, Student> kafkaTemplate;

    public String pushIntoKafka(String topic, Student student) {
    try {
    kafkaTemplate.send(topic, student);
    return "success";

    } catch (Exception e) {
    return "failed";
    }
    }

    }