ruote - open source ruby workflow and bpm engine Developed by John Mettraux jmettraux.wordpress.com Presented by Kenneth K...
Workflows? BPM? <ul><li>“Improved state machine”
Long running processes, long-lived process interpreter
Diverse participants
Complex rules & decisions
Implement clearly defined business processes </li></ul>
Joe's Mortgages <ul><li>Applies on your behalf at seven different institutions
Selects the best deal for you
Handles application for you
You sign
You buy
You pay </li></ul>
State Machine <ul><li>:requested
:evaluation
:acquired
:accepted
:applied
:approved </li></ul><ul><li>Where?
When?
Rate?
Comparison?
Who? </li></ul>
Rule: Notify Client when 4 quotes are received aasm_state :pending_four_left aasm_state :pending_three_left aasm_state :pe...
Rule: Wait up to 7 days for quotes aasm_state :pending_four_remaining_timeout aasm_state :pending_three_remaining_timout a...
Recap <ul><li>State machines are only valuable when they have a few, well defined states
Tempted to setup hundreds of states, with complex transitions
State machines help manage the  results  of real life processes, not the  processes </li></ul>
Modified State Machine class Mortgage aasm_initial_state :pending aasm_state :pending aasm_state :quoted aasm_state :appli...
Enter ruote <ul><li>Clearly defined DSL for workflow
Clearly defined processes </li><ul><li>Expressions
Participants </li></ul><li>Concurrent tasks
Timeouts
Easy decision making </li></ul>
Expressions <ul><li>Utility statements that give structure to your processes
Conditional statements that facilitate branching and merging patterns </li></ul>
Upcoming SlideShare
Loading in...5
×

Ruote in 20 Minutes

12,811

Published on

A quick introduction to the Ruote workflow and BPM engine by John Mettraux, presented by myself at the third monthly Ruby on Beer meetup.

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
12,811
On Slideshare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
164
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

Transcript of "Ruote in 20 Minutes"

  1. 1. ruote - open source ruby workflow and bpm engine Developed by John Mettraux jmettraux.wordpress.com Presented by Kenneth Kalmer in 20 minutes opensourcery.co.za
  2. 2. Workflows? BPM? <ul><li>“Improved state machine”
  3. 3. Long running processes, long-lived process interpreter
  4. 4. Diverse participants
  5. 5. Complex rules & decisions
  6. 6. Implement clearly defined business processes </li></ul>
  7. 7. Joe's Mortgages <ul><li>Applies on your behalf at seven different institutions
  8. 8. Selects the best deal for you
  9. 9. Handles application for you
  10. 10. You sign
  11. 11. You buy
  12. 12. You pay </li></ul>
  13. 13. State Machine <ul><li>:requested
  14. 14. :evaluation
  15. 15. :acquired
  16. 16. :accepted
  17. 17. :applied
  18. 18. :approved </li></ul><ul><li>Where?
  19. 19. When?
  20. 20. Rate?
  21. 21. Comparison?
  22. 22. Who? </li></ul>
  23. 23. Rule: Notify Client when 4 quotes are received aasm_state :pending_four_left aasm_state :pending_three_left aasm_state :pending_two_left aasm_state :pending_one_left aasm_state :pending_but_notified_client ... aasm_state :is_this_ridiculous_or_what?
  24. 24. Rule: Wait up to 7 days for quotes aasm_state :pending_four_remaining_timeout aasm_state :pending_three_remaining_timout aasm_state :pending_two_remaining_timout aasm_state :pending_one_remaining_timout … aasm_state :call_recruiter_for_new_dev!
  25. 25. Recap <ul><li>State machines are only valuable when they have a few, well defined states
  26. 26. Tempted to setup hundreds of states, with complex transitions
  27. 27. State machines help manage the results of real life processes, not the processes </li></ul>
  28. 28. Modified State Machine class Mortgage aasm_initial_state :pending aasm_state :pending aasm_state :quoted aasm_state :applied aasm_state :approved aasm_state :rejected end
  29. 29. Enter ruote <ul><li>Clearly defined DSL for workflow
  30. 30. Clearly defined processes </li><ul><li>Expressions
  31. 31. Participants </li></ul><li>Concurrent tasks
  32. 32. Timeouts
  33. 33. Easy decision making </li></ul>
  34. 34. Expressions <ul><li>Utility statements that give structure to your processes
  35. 35. Conditional statements that facilitate branching and merging patterns </li></ul>
  36. 36. Participants <ul><li>A point in the process where work gets done
  37. 37. Can be automated code
  38. 38. Can be human interaction
  39. 39. Ruote provides plenty of participants out the box
  40. 40. Breeze to write new ones </li></ul>
  41. 41. First round: Participants class MortgageApplication < OpenWFE::ProcessDefinition sequence do institution_1 :activity => 'Mortgage Quote' institution_2 :activity => 'Mortgage Quote' institution_3 :activity => 'Mortgage Quote' institution_4 :activity => 'Mortgage Quote' institution_5 :activity => 'Mortgage Quote' institution_6 :activity => 'Mortgage Quote' institution_7 :activity => 'Mortgage Quote' end end
  42. 42. Problems so far <ul><li>Will request quotations in serial
  43. 43. 14 days to complete if each institution takes 2 days on average </li></ul>
  44. 44. Concurrency! <ul><li>Not the Erlang kind, the business kind
  45. 45. Send all requests in one go, and continue the process once we've received at least 4 quotes
  46. 46. Also, quote process may not take longer than 7 days to complete </li></ul>
  47. 47. Second round: Concurrency and Timeout class MortgageApplication < OpenWFE::ProcessDefinition sequence do timeout :after => '7d' do concurrence :count => 4 do institution_1 :activity => 'Mortgage Quote' institution_2 :activity => 'Mortgage Quote' institution_3 :activity => 'Mortgage Quote' institution_4 :activity => 'Mortgage Quote' institution_5 :activity => 'Mortgage Quote' institution_6 :activity => 'Mortgage Quote' institution_7 :activity => 'Mortgage Quote' e nd end end end
  48. 48. Achievements so far <ul><li>Quotations requested simultaneously
  49. 49. Process will take 7 days at most to complete
  50. 50. First 4 institutions stand the chance of earning new business
  51. 51. Mortgage is still “pending” </li></ul>
  52. 52. Rule: Joe can re-request quotes <ul><li>Joe drives a hard bargain
  53. 53. Can request quotes any number of times
  54. 54. But, wants to let the client know he's doing his best! </li></ul>
  55. 55. Third round: Bargain hard class MortgageApplication < OpenWFE::ProcessDefinition sequence do loop do concurrence :timeout => '7d', :count => 4 do institution_1 :activity => 'Mortgage Quote' # ... e nd joe :activity => 'Review quotes' _break :if => “${f:joe_happy}” email :activity => “Getting new quotes”, :to => “${f:client.email}” end end end
  56. 56. Achievements so far <ul><li>Loop used to keep the quote request process running until Joe is happy, or cancels the process
  57. 57. Client notified everytime the quote request process starts all over again
  58. 58. First glimpse of workitems
  59. 59. Mortgage is still “pending” </li></ul>
  60. 60. Workitems? <ul><li>The internal “message” passed from participant to participant
  61. 61. They're JSON friendly Ruby hashes
  62. 62. Participants can modify workitems
  63. 63. Processes can be launched with an initial payload, client details in this case, which is accessed through the workitems
  64. 64. Workitem attributes accessed in process definitions through the “dollar notation” </li></ul>
  65. 65. Quote found, action the client class MortgageApplication < OpenWFE::ProcessDefinition sequence do loop do # ... end secretary :activity => “Send client application forms” end end
  66. 66. Application received, apply at institution class MortgageApplication < OpenWFE::ProcessDefinition sequence do # ... secretary :activity => “Send client application forms” participant :ref => “${f:selected_institution}”, :activity => “Apply for mortgage” end end
  67. 67. Achievements so far <ul><li>Dynamic participant specification from workitem attributes
  68. 68. Another human participant
  69. 69. Mortgage now in “applied” state </li></ul>
  70. 70. Let Joe Know <ul><li>Joe reviews the results of the application, and notifies the client
  71. 71. Might attempt to restart the entire process </li></ul>
  72. 72. Joe has last say class MortgageApplication < OpenWFE::ProcessDefinition sequence do # ... participant :ref => “${f:selected_institution}”, :activity => “Apply for mortgage” joe :activity => “Review application results” end end
  73. 73. What happens here? <ul><li>Joe will inform the client of the institutions response
  74. 74. Mortgage will stay in “applied” state, or move to “approved”/”rejected” states
  75. 75. Process ends </li></ul>
  76. 76. Possibilities from here <ul><li>Automated decision making </li><ul><li>Decision tables
  77. 77. Better conditional tests </li></ul><li>Automated response processing, streamlines the feedback loop and decision making
  78. 78. Harass institutions that don't respond within 2 days of process timeout
  79. 79. Joe improves his handicap </li></ul>
  80. 80. Ruote & AASM <ul><li>Great combination
  81. 81. Ruote handles business logic, AASM the state
  82. 82. AASM becomes skinny, ruote stays declarative </li></ul>
  83. 83. More ruote: Listeners <ul><li>Start process, or wait for </li><ul><li>Messages from SQS
  84. 84. Jabber messages
  85. 85. Atom feed entries </li></ul></ul>
  86. 86. More ruote: Cancel, cursors, replay & redo <ul><li>When processes are cancelled, run sub-processes for “cleanup” tasks
  87. 87. Replay failed steps
  88. 88. Redo steps based on conditions
  89. 89. Jump to any point in the workflow using cursors </li></ul>
  90. 90. More ruote: ruote-fluo <ul><li>Graphical representation of process definitions
  91. 91. Edit process definitions on the fly </li></ul>
  92. 92. More ruote: Active*Participants <ul><li>ActiveRecordParticipant </li><ul><li>Save workitem information in database </li></ul><li>ActiveResourceParticipant </li><ul><li>Interact with any Rails resource as DHH intended you to do </li></ul></ul>
  93. 93. Shameless Self Promotion <ul><li>Developed the JabberParticipant and JabberListener now bundled with ruote
  94. 94. Added support for daemonizing ruote-rest
  95. 95. In talks on refactoring ruote-rest to become preferred “Rails-friendly” implementation of ruote </li></ul>
  96. 96. Summary <ul><li>Process definitions built up from expressions
  97. 97. Expressions are “steps in the workflow”
  98. 98. Participants perform explicit function during workflow
  99. 99. Workitems used as “internal messaging” mechanism between expressions/participants
  100. 100. The best complement to any state machine implementation
  101. 101. Simplifies complex business process implementations
  102. 102. You have full control over the entire process </li></ul>
  103. 103. Thank You opensourcery.co.za @kennethkalmer openwferu.rubyforge.org #ruote on Freenode groups.google.com/group/openwferu-users @jmettraux
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×