Spring Tips: Spring Statemachine

Поделиться
HTML-код
  • Опубликовано: 26 сен 2024
  • Speaker: Josh Long
    / starbuxman
    Hi Spring fans! In this installment we'll look at how to extricate process state - valuable for coordinating long running or mutli-actor processes - from business logic with Spring Statemachine.

Комментарии • 50

  • @rajsekharmahapatro
    @rajsekharmahapatro Месяц назад

    i watched this 4-5 years back it did not make me any sense, and now in 2024 its crystal clear :D

  • @Temofey1989
    @Temofey1989 6 лет назад +1

    A good approach to think about.
    Thanks for the video, Josh.

  • @yongqiangli
    @yongqiangli 3 года назад

    Thanks a lot! Pretty good explanation about using Spring Boot state machine and very helpful!

  • @viorelcasapu9951
    @viorelcasapu9951 5 лет назад

    GREAT introduction in spring statemachine! Thanks!

  • @donwald3436
    @donwald3436 6 лет назад +1

    Thank you! This is a good starting point.

  • @visavasam
    @visavasam 9 месяцев назад

    Great Tutorial. Thank you

  • @prateekashtikar8631
    @prateekashtikar8631 3 года назад +1

    Can you please create tutorial on Saga - considering Orchestration ?

  • @Satishkumar-rx7oy
    @Satishkumar-rx7oy 2 года назад

    Well explained. Thanks

  • @马腾-w9y
    @马腾-w9y 3 года назад

    Thanks for your sharing!

  • @mutasemjubran8268
    @mutasemjubran8268 Год назад

    Hi Thanx for this tutorial. Do you know how to persist using JPA?

  • @YidingHe
    @YidingHe 4 года назад +1

    It scares me how complex it is. Can't we just pass order id, state and event and get a next state and persist it outside the state machine instead of using an interceptor?

  • @Parames789
    @Parames789 2 года назад +1

    Hi.... Is this code available anywhere on the web or anyone has this code working open to share..

  • @elijahtang7499
    @elijahtang7499 4 года назад

    thank u very much . it solved my question!

  • @liuckan
    @liuckan 6 лет назад

    The ID of the state machines is null every time (56:04), although you're passing the orderId, because of the "doWithAllRegions->reset" bits. The SM are different on every step of the workflow, because of the factory, but the question is how fast each instance is stopped and discarded? Let's say you wanna transition from SI -> A -> B states - what is happening is basically SI to A - get new SM, do 1 node transition, stop the SM; A to B -> get new SM, do 1 node transition, stop the SM; What conditions needs to be satisfied for the SM1 to stop, having in mind A is not a final state? Should it be stopped manually after the transition is done?

  • @BrijeshPatelEngineer
    @BrijeshPatelEngineer 5 лет назад

    Great video. I would recommend start with flow diagram at start which sets the visuals on the state changes happening.
    Overall nice video. I will try to implement it and link it in my video soon.

    • @waltonhumphrey8908
      @waltonhumphrey8908 2 года назад

      Hi, did you implement one with flow diagram?

    • @BrijeshPatelEngineer
      @BrijeshPatelEngineer 2 года назад

      @@waltonhumphrey8908 yeah i was able to do that but havent got a chance to record the video.

  • @Ajayhanand
    @Ajayhanand Год назад

    what if the prestatechange method succeeeds and start change fails?

  • @MrBENNA-lf9ic
    @MrBENNA-lf9ic 4 года назад

    great work thank you!

  • @martinsefcik
    @martinsefcik 6 лет назад +2

    I would like to see such example together with @Transactional
    For example if paymentConfirmationNumber is attribute of Order entity and I want to set this attribute to order entity on PAID state entry action and also have it saved together with order state within the same transaction.
    And the second case would be to have some post PAID state change action which will be executed immediately after PAID status is changed, but in the new transaction.
    So state is changed saved and committed in one transaction, such transaction ends and then post state change action will be executed in new transaction.
    What is the best approach for such scenarios? I cannot find such examples in spring state machine docs and also anywhere on internet.

    • @anushriaithal2642
      @anushriaithal2642 6 лет назад

      Hi, did you find any help on this? I am looking for similar examples.

    • @martinsefcik
      @martinsefcik 6 лет назад

      Anushri Aithal No, I didn't find anything yet.

    • @Ajayhanand
      @Ajayhanand Год назад

      @@martinsefcik i guess then one phase has to be a complete one transaction in itself. By design on phase cannot overlap the other phase.

  • @savitasunilkumarpatil107
    @savitasunilkumarpatil107 5 лет назад +1

    In am looking for with rest calls

  • @NehaGupta87
    @NehaGupta87 5 лет назад +10

    Really nice and helpful video. However, I have a question Josh:
    If I deploy my state machine on different clusters and supposedly one of the clusters goes down, then how will the states be restored in memory again?

    • @iTzLiOoN
      @iTzLiOoN 3 года назад

      good question, have you validated this scenario?

    • @Ajayhanand
      @Ajayhanand Год назад

      I had a same question, did any one get the answer to this question?

    • @Ajayhanand
      @Ajayhanand Год назад

      may be we have to save the phase in the db and then re-construct the statemachine by going through but passing through different phases, like if the service crashed at 3rd phase completion, we have to then go through 1 and 2 and go until the phase is 3 automatically , quite absurd

  • @gennadijdegterjow8457
    @gennadijdegterjow8457 4 года назад +1

    Good information about state mashine, but wrong usage of logging framework. Using String.format or string concatenation you kill all benefits. With ERROR log level you will simple burn CPU and produce garbage. Use placeholders {} to format your log entries

  • @serhiimanko4942
    @serhiimanko4942 5 лет назад

    Awesome!

  • @CloudAndCode
    @CloudAndCode 6 лет назад

    Why boot application always exits after the operation is completed. How do keep the application running?

    • @ch4dix
      @ch4dix 6 лет назад +1

      This video was about a command line runner application. If you need it in a running service you need to create either a Rest or MVC service or a scheduler of some sort.

  • @Third_Eyeee
    @Third_Eyeee 6 лет назад

    Thanks for the amazing video, this is a great reference for me.
    but i have some doubts on initial state,parent state, sub states etc. and i also don't know that is it possible to create nested state machine(machine in side a machine)
    please give me some suggestion and reference(book name ,blogs,docs) from where i can clear my all doubts.
    please create 5-10 mint video for some states listeners ,states mathods and it's use in multithreading environment(distributed system) if it is possible.

    • @MykhayloS
      @MykhayloS 6 лет назад

      Check the notion of "regions" (or "orthogonal regions").

  • @ifyum
    @ifyum 5 лет назад

    imports?

  • @ltmikepick
    @ltmikepick 2 года назад

    Where's your mac?

  • @A3A3adamsan
    @A3A3adamsan 3 года назад +1

    Am I the only one who thinks this is unnecessarily overcomplicated?

  • @Randomisticful
    @Randomisticful 5 лет назад +5

    Try to speak slower while pronouncing every word. Why rush?

    • @AlexanderRadchenkoRus
      @AlexanderRadchenkoRus 3 года назад

      Just turn on subtitles, youtube is quite good at recognizing fast speech.

    • @zoladkow
      @zoladkow 11 месяцев назад

      too much coffee 🤔

  • @shakhawatstech9616
    @shakhawatstech9616 6 лет назад

    Awesome !

  • @kennethcarvalho3684
    @kennethcarvalho3684 3 года назад

    Nice but you could have started with a good slide on State machines during your intro instead of a dark screen

  • @amarpathak1991
    @amarpathak1991 4 года назад

    Amazing video. it is really helpful to start using spring state machine. Loved the explanation. Thanks you Josh !

  • @eirikbremnes2860
    @eirikbremnes2860 5 лет назад

    Awesome video! Thanks!! Keep up the good work!!!

  • @barbaraxenou8192
    @barbaraxenou8192 6 лет назад +1

    very good thanks
    is it possible to have the source code

    • @JoshLong
      @JoshLong 6 лет назад +3

      Hi buddy thanks for watching. the source code is github.com/spring-tips/statemachine

    • @ManishSahu-fu5ml
      @ManishSahu-fu5ml 4 года назад

      @@JoshLong Thanks a lot for providing source code link

    • @arjungupta4672
      @arjungupta4672 2 года назад

      @@JoshLong Thanks! Really helpful video along with source code.

  • @chitthiaayeehai
    @chitthiaayeehai 3 года назад

    So the state machine is only to track the state after all ?
    Why we need this ?
    We can simply create an event n pass in Kafka for the next service to pickup...
    What r other the use cases, pls explain on that

    • @Ajayhanand
      @Ajayhanand Год назад

      none..i think they just avoided the if an else in your solution when you read a message to understand what to do next in an if else state on consumption