Spring Boot + Apache Kafka Tutorial - #12 - Create REST API to Send JSON Object

Поділитися
Вставка
  • Опубліковано 11 тра 2022
  • Welcome to Spring Boot + Apache Kafka Tutorial series.
    In this lecture, we will create a REST API to send a JSON message in request. The REST API intern converts JSON into a User object and sends it to Kafka Producer. Kafka Producer intern sends that user object to Kafka topic.
    #springboot #kafka #javaguides
    Complete playlist at • Spring Boot + Apache K...
    GitHub link: github.com/RameshMF/springboo...

КОМЕНТАРІ • 32

  • @user-oq2qz1st3f
    @user-oq2qz1st3f Рік тому +1

    Спасибо огромное!!!! Ты очень хорошо все объясняешь.👍👍👍👍

  • @wahyuusman6777
    @wahyuusman6777 Рік тому

    many thanks about your tutorial, cuz your video i very help for learning about kafka

  • @shailendraraj4951
    @shailendraraj4951 Рік тому

    great explanation

  • @johnbrooks8839
    @johnbrooks8839 Рік тому +4

    Those who are getting the error trying to cast your User object to a String may need to update your producer properties to have a key serializer and value serializer instead of "deserializer".

  • @Andrzej3935
    @Andrzej3935 8 місяців тому

    Greate lessons

  • @tonydeveloperdndndn
    @tonydeveloperdndndn Рік тому

    Nice presentation and explanation.

  • @meduriravindra4238
    @meduriravindra4238 2 роки тому

    Please explain how to consume old data from Kafka after the old data get updated. Is it a possible scenario atleast from interview point of view ?

  • @pavanraju6485
    @pavanraju6485 Рік тому

    How to consume data by using browser or postman?

  • @anshikamishra5938
    @anshikamishra5938 11 місяців тому

    Some of the windows commands are not working for me giving "The syntax for the command is incorrect" specially when using --from-beginning

  • @krishnamadhav7639
    @krishnamadhav7639 3 місяці тому

    At 2:07, you have added PostMapping("/publish") and in the previous video in MessageController class you have added GetMapping("/publish"). Can you please explain the reason behind it? Please clarify this.
    As per my understanding at both the places it should be GetMapping annotation only.

  • @arthurmukelyan404
    @arthurmukelyan404 4 місяці тому

    Hi, I am getting 405 request method not supported, but I can’t understand why, anyone can help me?

  • @adityakendhe5630
    @adityakendhe5630 Рік тому

    hello sir,
    I am getting null pointer exception related to kafka template while using rest api to send json object on console.
    And in postman it is showing internal server error.
    please help.

    • @JustFootBallThings623
      @JustFootBallThings623 Рік тому

      I am getting the same error too did u get solution?

    • @adityakendhe5630
      @adityakendhe5630 Рік тому

      @@JustFootBallThings623 my code is correct...so i guess its due to some of the libraries or dependencies missing on our IDE unlike used in lecture. In better way i skipped it and and continued with lecture.
      in next lecture he made real time project. Thats important.

    • @lky100047
      @lky100047 Рік тому

      add
      import org.apache.kafka.common.serialization.StringSerializer;
      import org.springframework.kafka.support.serializer.JsonSerializer;
      to every java class work for me

    • @poojagamskar6872
      @poojagamskar6872 Рік тому +1

      recheck the previous learning vedio u must have missed creating constructor for kafka template,so u r getting null pointer exception

  • @elakkiyap5509
    @elakkiyap5509 Рік тому

    hai sir. i tried to send Json Message to kafka topic but am getting internal server error in postman . As well as in intellij, ERROR [dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.kafka.common.errors.SerializationException: Can't convert value of class in.inspired.services.model.User to class org.apache.kafka.common.serialization.StringSerializer specified in value.serializer] with root cause java.lang.ClassCastException: class in.inspired.services.model.User cannot be cast to class java.lang.String (in.inspired.services.model.User is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')...how to overcome this error. kindly help in this

  • @vinay2841
    @vinay2841 Рік тому

    Anyone please help me to resolve this error org.apache.kafka.common.errors.SerializationException: Can't convert value of class com.vinay.kafka.payload.User to class org.apache.kafka.common.serialization.StringSerializer

    • @shanmugamsekar2070
      @shanmugamsekar2070 Рік тому

      i also get this error

    • @vinay2841
      @vinay2841 Рік тому

      @@shanmugamsekar2070 Have u got a solution?

    • @sanyamkharche6646
      @sanyamkharche6646 Рік тому

      @@vinay2841
      To ensure that the User class is properly serialized and deserialized as JSON, you need to add the necessary Jackson annotations.e.g. @JsonProperty annotation. Add this dependency in your pom.xml if using a spring boot project.

      com.fasterxml.jackson.core
      jackson-databind

  • @MDAnashAnsari
    @MDAnashAnsari 6 місяців тому

    Replace your KafkaConsumer class code with the below code if you are getting :- org.apache.kafka.common.errors.SerializationException: Can't convert value of class com.vinay.kafka.payload.User to class org.apache.kafka.common.serialization.StringSerializer
    public class KafkaConsumer {
    @KafkaListener(topics = "nepdroid", groupId = "myGroup")
    public void consume(User user) {
    log.info(String.format("Message received -> %s", user.toString()));
    }
    }