SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
A simple workflow system



        David Peterson
      peterson@orbitec.com.au
What is a workflow?


A process that moves through a
sequence of steps (from start and
   finish) in order to perform
          some function
Examples


    Fulfilling an order
●




    Publishing documents / content
●




    Approving a request
●
A few things in common ...


    Typically multi-step
●



    Performed asynchronously
●



    May be long-running
●



    Steps may be conditional
●



    Each step may need to do an operation
●
The Idea


Many simple workflows
can be modelled as a
finite state machine


      (Not all)
acts_as_state_machine


    AASM to friends!
●



    Rails plugin by Scott Barron
●




    Provides:
●


        A simple FSM implementation
    ●


        A DSL for expressing FSM in Ruby code
    ●
http://elitists.textdriven.com/svn/plugins/
       acts_as_state_machine/trunk/
# Basic workflow example
class ActionWorkflow < ActiveRecord::Base

 acts_as_state_machine :initial => :created,
  :column => 'status'

 state :created
 state :approved
 state :rejected
 state :cancelled

 event :approve { transitions :to => :approved, :from
 => :created }

 event :cancel { transitions :to => :cancelled, :from
 =>[:created, :approved, :rejected] }
 ...
end
AASM provides some methods


    An action! method for each event
●



    A query? method for each state
●




Examples:
    workflow.approve!   # moves to approved state
    workflow.cancelled? # Returns boolean
Guards

    event :approve { transitions :to => :approved, :from
     => :created, :guard => Proc.new {|w| !w.expired?}}


    Allows conditions on transitions
●



    Transition is not available unless
●


    condition is met
    Some conditions may be expressed
●


    best in your code, not in guards
Callbacks
    state :approved, :after => :on_submit
    state :approved, :after => :Proc.new {|m| m.abc }



    Available hooks :enter, :after and :exit
●



    Callbacks provide a way to do some
●


    operation when a transition occurs
     def on_submit
       record_action
       ...
     end
Other useful stuff
# Fire your actions (cleanly)
  attr_accessor :action
  def action_workflow
    eval(quot;self.#{self.action}!quot;) unless self.action.nil?
  end


# Add an audit trail ...
  has_many :actions, :class_name => quot;WorkflowActionquot;
  def record_action
   self.actions << WorkflowAction.create(
    :comment => self.comment, :actioner_id =>
    self.acting_person, :state => self.state)
  end
A few caveats
    A minor change to AASM .rb required
●


        Avoids runtime error (on 1.2.3 anyway!)
    ●




    Also added a couple of things locally
●


        Lourens Naude's method (mis-named)
    ●


        A corrected next_events_for_current_state
    ●




    Ask me for the patch if you're keen
●
# Retrieves next states for current state

 def next_events_for_current_state
  events = []
  self.class.read_inheritable_attribute(
    :transition_table).each do |key, value|
      value.each do |transition|
       events << key if transition.from ==
          current_state()
        end
   end
 events
end
Remarks
AASM makes it very simple to implement
 a simple workflow model
        A full workflow system is more complex
    ●


        acts_as_coloured_petri_net :)
    ●




    Piston is your friend ... especially when
●


    making local modifications to plugins
Parting thought
Q: What are the three most important
 ideas in programming?

  1. Abstraction
  2. Abstraction
  3. Abstraction


(Hudak, 2000)

Más contenido relacionado

La actualidad más candente

Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
PerconaPerformance
 
Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012
Mike Willbanks
 
Advanced Load Runner
Advanced Load RunnerAdvanced Load Runner
Advanced Load Runner
telab
 
Kanban - Class of Service (To Manage Incidents in a DevOps Team)
Kanban - Class of Service (To Manage Incidents in a DevOps Team)Kanban - Class of Service (To Manage Incidents in a DevOps Team)
Kanban - Class of Service (To Manage Incidents in a DevOps Team)
Anurag Shrivastava
 

La actualidad más candente (20)

Ct102 using ltmom to move to sap s4 hana
Ct102  using ltmom to move to sap s4 hanaCt102  using ltmom to move to sap s4 hana
Ct102 using ltmom to move to sap s4 hana
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal info
 
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
 
Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)
Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)
Jonathon Wright - Intelligent Performance Cognitive Learning (AIOps)
 
bed-con 2015 - From Virtual Machines to Containers
bed-con 2015 - From Virtual Machines to Containersbed-con 2015 - From Virtual Machines to Containers
bed-con 2015 - From Virtual Machines to Containers
 
Task flow
Task flowTask flow
Task flow
 
Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...
Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...
Case of the Unexplained Support Issue – Troubleshooting steps for diagnosing ...
 
Object Oriented Programming I
Object Oriented Programming IObject Oriented Programming I
Object Oriented Programming I
 
Load testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew SiemerLoad testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew Siemer
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
 
Architecting for the cloud storage build test
Architecting for the cloud storage build testArchitecting for the cloud storage build test
Architecting for the cloud storage build test
 
BlazeMeter- Effective Performance Reporting
BlazeMeter- Effective Performance ReportingBlazeMeter- Effective Performance Reporting
BlazeMeter- Effective Performance Reporting
 
Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012
 
SAP Workflow Po create workflow by pavan golesar
SAP Workflow Po create workflow by pavan golesarSAP Workflow Po create workflow by pavan golesar
SAP Workflow Po create workflow by pavan golesar
 
Load Runner
Load RunnerLoad Runner
Load Runner
 
Advanced Load Runner
Advanced Load RunnerAdvanced Load Runner
Advanced Load Runner
 
Silk Performer Presentation v1
Silk Performer Presentation v1Silk Performer Presentation v1
Silk Performer Presentation v1
 
Synthetic web performance testing with Selenium
Synthetic web performance testing with SeleniumSynthetic web performance testing with Selenium
Synthetic web performance testing with Selenium
 
Building software by feature with immutable infrastructures on AWS
Building software by feature with immutable infrastructures on AWSBuilding software by feature with immutable infrastructures on AWS
Building software by feature with immutable infrastructures on AWS
 
Kanban - Class of Service (To Manage Incidents in a DevOps Team)
Kanban - Class of Service (To Manage Incidents in a DevOps Team)Kanban - Class of Service (To Manage Incidents in a DevOps Team)
Kanban - Class of Service (To Manage Incidents in a DevOps Team)
 

Destacado

Events Workflow diagram
Events Workflow diagramEvents Workflow diagram
Events Workflow diagram
Colin Thomson
 
Architecture of message oriented middleware
Architecture of message oriented middlewareArchitecture of message oriented middleware
Architecture of message oriented middleware
Likan Patra
 
Developing a PLN and open co-learning opportunities #UoRsocialmedia
Developing a PLN and open co-learning opportunities #UoRsocialmediaDeveloping a PLN and open co-learning opportunities #UoRsocialmedia
Developing a PLN and open co-learning opportunities #UoRsocialmedia
Sue Beckingham
 

Destacado (20)

Corporate Workflow Process - Complaints and Legal Matters (illustration)
Corporate Workflow Process - Complaints and Legal Matters (illustration)Corporate Workflow Process - Complaints and Legal Matters (illustration)
Corporate Workflow Process - Complaints and Legal Matters (illustration)
 
Neuro4j Workflow Overview
Neuro4j Workflow OverviewNeuro4j Workflow Overview
Neuro4j Workflow Overview
 
Scalable web-based workflow platform
Scalable web-based workflow platformScalable web-based workflow platform
Scalable web-based workflow platform
 
workflow in temporal state machine v1
workflow in temporal state machine v1workflow in temporal state machine v1
workflow in temporal state machine v1
 
Workflow Foundation 4
Workflow Foundation 4Workflow Foundation 4
Workflow Foundation 4
 
Message oriented middleware
Message oriented middlewareMessage oriented middleware
Message oriented middleware
 
Windows Workflow Foundation
Windows Workflow FoundationWindows Workflow Foundation
Windows Workflow Foundation
 
Events Workflow diagram
Events Workflow diagramEvents Workflow diagram
Events Workflow diagram
 
JBoss BPM Suite 6 Tech labs
JBoss BPM Suite 6 Tech labsJBoss BPM Suite 6 Tech labs
JBoss BPM Suite 6 Tech labs
 
Message Oriented Middleware (MOM)
Message Oriented Middleware (MOM)Message Oriented Middleware (MOM)
Message Oriented Middleware (MOM)
 
Sending and receiving messages in mq queues
Sending and receiving messages in mq queuesSending and receiving messages in mq queues
Sending and receiving messages in mq queues
 
Workflow for XPages
Workflow for XPagesWorkflow for XPages
Workflow for XPages
 
The Workflow Reference Model
The Workflow Reference ModelThe Workflow Reference Model
The Workflow Reference Model
 
Djangocon 09 Presentation - Pluggable Applications
Djangocon 09 Presentation - Pluggable ApplicationsDjangocon 09 Presentation - Pluggable Applications
Djangocon 09 Presentation - Pluggable Applications
 
Architecture of message oriented middleware
Architecture of message oriented middlewareArchitecture of message oriented middleware
Architecture of message oriented middleware
 
Cognitive IBM Watson Services for Bluemix Developers
Cognitive IBM Watson Services for Bluemix DevelopersCognitive IBM Watson Services for Bluemix Developers
Cognitive IBM Watson Services for Bluemix Developers
 
Responsive Design Workflow: Mobilism 2012
Responsive Design Workflow: Mobilism 2012Responsive Design Workflow: Mobilism 2012
Responsive Design Workflow: Mobilism 2012
 
Career vs Health
Career vs HealthCareer vs Health
Career vs Health
 
Circuits 2011 in English
Circuits 2011 in EnglishCircuits 2011 in English
Circuits 2011 in English
 
Developing a PLN and open co-learning opportunities #UoRsocialmedia
Developing a PLN and open co-learning opportunities #UoRsocialmediaDeveloping a PLN and open co-learning opportunities #UoRsocialmedia
Developing a PLN and open co-learning opportunities #UoRsocialmedia
 

Similar a A simple workflow system using state machines

540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf
hamzadamani7
 
Intro to tsql unit 14
Intro to tsql   unit 14Intro to tsql   unit 14
Intro to tsql unit 14
Syed Asrarali
 
Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01
longtuan
 
Node js
Node jsNode js
Node js
hazzaz
 

Similar a A simple workflow system using state machines (20)

Os Whitaker
Os WhitakerOs Whitaker
Os Whitaker
 
540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf
 
Linux Cluster Job Management Systems (SGE)
Linux Cluster Job Management Systems (SGE)Linux Cluster Job Management Systems (SGE)
Linux Cluster Job Management Systems (SGE)
 
Getting Reactive with Cycle.js and xstream
Getting Reactive with Cycle.js and xstreamGetting Reactive with Cycle.js and xstream
Getting Reactive with Cycle.js and xstream
 
Automating EVA Workflows with AWS Step Functions
Automating EVA Workflows with AWS Step FunctionsAutomating EVA Workflows with AWS Step Functions
Automating EVA Workflows with AWS Step Functions
 
Velocity 2018 preetha appan final
Velocity 2018   preetha appan finalVelocity 2018   preetha appan final
Velocity 2018 preetha appan final
 
Intro to tsql unit 14
Intro to tsql   unit 14Intro to tsql   unit 14
Intro to tsql unit 14
 
Intro to tsql
Intro to tsqlIntro to tsql
Intro to tsql
 
File Processing - Batch Process Execution
File Processing - Batch Process ExecutionFile Processing - Batch Process Execution
File Processing - Batch Process Execution
 
File Processing - Process Execution Solution
File Processing - Process Execution SolutionFile Processing - Process Execution Solution
File Processing - Process Execution Solution
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance Meetup
 
Capistrano
CapistranoCapistrano
Capistrano
 
Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01
 
ReactJS
ReactJSReactJS
ReactJS
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slides
 
Node js
Node jsNode js
Node js
 
Container Orchestration from Theory to Practice
Container Orchestration from Theory to PracticeContainer Orchestration from Theory to Practice
Container Orchestration from Theory to Practice
 
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and ScalabilityIBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
 
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

A simple workflow system using state machines

  • 1. A simple workflow system David Peterson peterson@orbitec.com.au
  • 2. What is a workflow? A process that moves through a sequence of steps (from start and finish) in order to perform some function
  • 3. Examples Fulfilling an order ● Publishing documents / content ● Approving a request ●
  • 4. A few things in common ... Typically multi-step ● Performed asynchronously ● May be long-running ● Steps may be conditional ● Each step may need to do an operation ●
  • 5. The Idea Many simple workflows can be modelled as a finite state machine (Not all)
  • 6. acts_as_state_machine AASM to friends! ● Rails plugin by Scott Barron ● Provides: ● A simple FSM implementation ● A DSL for expressing FSM in Ruby code ●
  • 7. http://elitists.textdriven.com/svn/plugins/ acts_as_state_machine/trunk/
  • 8. # Basic workflow example class ActionWorkflow < ActiveRecord::Base acts_as_state_machine :initial => :created, :column => 'status' state :created state :approved state :rejected state :cancelled event :approve { transitions :to => :approved, :from => :created } event :cancel { transitions :to => :cancelled, :from =>[:created, :approved, :rejected] } ... end
  • 9. AASM provides some methods An action! method for each event ● A query? method for each state ● Examples: workflow.approve! # moves to approved state workflow.cancelled? # Returns boolean
  • 10. Guards event :approve { transitions :to => :approved, :from => :created, :guard => Proc.new {|w| !w.expired?}} Allows conditions on transitions ● Transition is not available unless ● condition is met Some conditions may be expressed ● best in your code, not in guards
  • 11. Callbacks state :approved, :after => :on_submit state :approved, :after => :Proc.new {|m| m.abc } Available hooks :enter, :after and :exit ● Callbacks provide a way to do some ● operation when a transition occurs def on_submit record_action ... end
  • 12. Other useful stuff # Fire your actions (cleanly) attr_accessor :action def action_workflow eval(quot;self.#{self.action}!quot;) unless self.action.nil? end # Add an audit trail ... has_many :actions, :class_name => quot;WorkflowActionquot; def record_action self.actions << WorkflowAction.create( :comment => self.comment, :actioner_id => self.acting_person, :state => self.state) end
  • 13. A few caveats A minor change to AASM .rb required ● Avoids runtime error (on 1.2.3 anyway!) ● Also added a couple of things locally ● Lourens Naude's method (mis-named) ● A corrected next_events_for_current_state ● Ask me for the patch if you're keen ●
  • 14. # Retrieves next states for current state def next_events_for_current_state events = [] self.class.read_inheritable_attribute( :transition_table).each do |key, value| value.each do |transition| events << key if transition.from == current_state() end end events end
  • 15. Remarks AASM makes it very simple to implement a simple workflow model A full workflow system is more complex ● acts_as_coloured_petri_net :) ● Piston is your friend ... especially when ● making local modifications to plugins
  • 16. Parting thought Q: What are the three most important ideas in programming? 1. Abstraction 2. Abstraction 3. Abstraction (Hudak, 2000)