Server-Sent Event + Spring Boot | Part 2

Sdílet
Vložit
  • čas přidán 20. 04. 2020
  • Thanks for watching and welcome to my channel. If you liked this tutorial, make sure to subscribe for more !
    On this tutorial we will explore a solution to Send Events to Specific User using Spring Boot and Server Sent Events.
    - Target a specific User
    - Create an EventSource to Subscribe to Spring Boot Application endpoint
    - Create Java Sseemitter, and handle completion, errors, and timeout
    - Remove stored emitter when it's not reached anymore
    - Dispatch Events to all clients
    - Use Postman to send Rest Requests
    IDE and tools used : Spring Tools (STS) IDE and Postman

Komentáře • 36

  • @experiencenano5352
    @experiencenano5352 Před 2 lety +1

    Superb explanation. Loved it. Thanks for keeping it simple for novice.

  • @ricardojohannsen374
    @ricardojohannsen374 Před 2 lety +1

    congratulation! the best tutorial od SSE with Spring!! Make a tutorial in this style from WebSockets with Spring and how to scale it

  • @yavuzselimcetinkaya4475
    @yavuzselimcetinkaya4475 Před 3 lety +1

    Great tutorial

  • @deepikamahulia3530
    @deepikamahulia3530 Před rokem +1

    Hi JavaGrowth, thank you for this great tutorial. I have one scenario. Let’s say the user is subscribing to receive sse events and events will be sent based on some topics received from kafka broker. Now suppose, the user has subscribed to pod1 but some event is being listened on pod3. Now how will I determine that on which pod I need to send sse event?
    Would be great if you could answer this.

  • @PLanBBeaTZ
    @PLanBBeaTZ Před 2 lety +1

    A great and straight forward tutorial on Sse!! Thanks for uploading. Just one question, would it make sense to store the subscriptions in a database? When yes, what information would you store?

    • @javagrowth6221
      @javagrowth6221  Před 2 lety +1

      Thanks for support bro. In my opinion the best options is to store subscriptions in redis

  • @inheritcode1473
    @inheritcode1473 Před 4 lety

    You saved my day.

  • @shivakrishna5120
    @shivakrishna5120 Před 3 lety +4

    Hi, JavaGrowth Thanks for the great tutorials. I think a small change is necessary for your code for emitters.remove(sseEmitter); this should be like emitters.remove(userID), and SSE has it's own limitations like we can open max 6 connections per host in a browser. it's better to discuss the pros and cons also so that newbies will choose the technologies based on their needs.
    once again thanks for the information.

    • @javagrowth6221
      @javagrowth6221  Před 2 lety +1

      Thanks for watching, i agree with you the subject is not as simple in big Applications and with many Users, some other components have to involve like RabbitMQ, and some Kafka. may be the subject of a future video.

    • @rajivkumar-ub6uj
      @rajivkumar-ub6uj Před 2 lety

      Is it true? I mean it can handle only at max of 6 connections? Can you suggest the various other methods?

    • @IvanRandomDude
      @IvanRandomDude Před 2 lety

      @@rajivkumar-ub6uj 6 connections per browser but it is HTTP1.1 limitation. Server Side Events are supposed to be streamed over HTTP2 anyway where that problem does not exists.

  • @TrueEnroi
    @TrueEnroi Před rokem +1

    Thank you.

  • @Nightedz
    @Nightedz Před 3 lety +1

    Thx a lot.

  • @blessyjulie4989
    @blessyjulie4989 Před 3 lety

    Hello sir! Thanks for the video ... Just one help, how to close the connection if the tab gets closed? the emitters list size is not reducing when closing the tab.

    • @javagrowth6221
      @javagrowth6221  Před 3 lety

      Thanks for watching, on this use case you have to detect "Browser Closing",
      window.onbeforeunload = function () {
      /* Here you try to close SSE connection with server */
      };

  • @ajaysrivas6791
    @ajaysrivas6791 Před 3 lety +1

    shouldn't the emitters hashMap be static? Great tutorial btw!

    • @javagrowth6221
      @javagrowth6221  Před 2 lety +1

      Yes maybe, but the tutorial is just to meet with SSE. on other big applications you have to store users and some RabbitMQ or Kafka stuffs.

  • @izzykoding9114
    @izzykoding9114 Před 3 lety +1

    Nice tutorial... can I use this with HTML/JavaScript and PHP only? Client side using HTML/JavaScript and PHP for the server side. I want to use this for a web based application that require to send SSE to each user separately.

    • @javagrowth6221
      @javagrowth6221  Před 2 lety +1

      Yes of corse, the advantage of using Spring in your backend is that it already have some great library to abstract some basic SSE features. Welcome.

  • @nahlaaroua9509
    @nahlaaroua9509 Před 3 lety +1

    hi! thank you for your video but how can I send a message by spring boot and angular frontend for a specific user?

  • @maxwbn27
    @maxwbn27 Před 8 měsíci +1

    Thanks al lot for such a nice tutorial and great explanation. Can you share the source Code with us, so that we can have a look on it? :)

  • @ramin2881
    @ramin2881 Před rokem +1

    Hi. Thanks for video. Does is support sending data to android/iOS apps?

    • @javagrowth6221
      @javagrowth6221  Před rokem

      Thanks for your feedback ! i never did any development for Andriod apps only Webapp bro.

  • @MishaMinion327
    @MishaMinion327 Před rokem +1

    Thanks! This was the easiest turorial to understand about this topic. I implemented this and it's working perfectly in my local, but I deployed it on Azure and there it takes too long to connect and it's always giving me a 504 error. Any idea of how could I find a solution for this?

  • @akshayhande3759
    @akshayhande3759 Před 3 lety

    Great explanation. I implemented it but user specific code is not working for multiple browser. any suggestions?

    • @javagrowth6221
      @javagrowth6221  Před 3 lety +1

      SSE is not compatible with evey browser, but a JS SSE prototype should exists.

  • @Manu-in3zf
    @Manu-in3zf Před 3 lety

    Thanks for such a nice tutorial and great explanation.
    this is what I was looking, for one of the use cases of my project.
    also can you please share the code git link,?

    • @javagrowth6221
      @javagrowth6221  Před 3 lety

      Thanks for watching !

    • @Manu-in3zf
      @Manu-in3zf Před 3 lety

      @@javagrowth6221 I want to subscribe SSE after login, I am using Spring Security with Oatu2 jwt.
      so while creating EventSource(url) in my js (Angular), did't find any option to pass Header.
      can you please here, how sse will subscribe and send in a secure enviroment?

  • @ssmarishettyable
    @ssmarishettyable Před 3 lety

    Wonderful... can you please add next one please?