Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

E-State: An Enterprise State Machine

A framework inspired by ROOM

E-State and Workflow
Workflow and state machines are, as argued in my earlier article, "State Machines and Workflow" (WLDJ, Vol. 3, issue 1), complementary implementation strategies for process-oriented applications. The state approach is a powerful abstraction for the succession of milestones found in many business processes. On the other hand, workflow - in particular, the Business Process Modeler (BPM) component of BEA WebLogic Integration - provides important enterprise-level services, such as external system integration, human worklist and task management, events and timers, and XML messaging processing. As the earlier article pointed out, a hybrid state-workflow solution has the following parts:

  1. A state machine framework, consisting of:
    - A state model: A set of states and transitions, expressed in an XML document.
    - Actor database: An entity that has state. The state of the actor is persisted to a database by the state machine.
    - State machine engine: Injects events into an actor's state model and updates state accordingly. It also calls user-defined action classes when a state is entered or exited or a transition occurs.
    - Action classes: User-defined Java classes that respond to the entry or exit of a state or the execution of a transition for an actor in a given state model.
  2. A BPM workflow that receives an event and injects it into the state machine.
  3. A BPM workflow that sets a timer and injects a timeout event into the state machine when the timer expired.
  4. A BPM workflow that is called by a state action to assign a worklist task or interact with an external system.
E-State is a reference implementation of the first part: the state machine framework. This article discusses its architecture.

E-State Architecture
Methodology

E-State's state models are based on those in the Real-time Object-Oriented Modeling (ROOM) methodology. ROOM state charts are hierarchical, meaning that a given state can have substates. This simple idea is disproportionately powerful. Flat state models simply don't scale from a human understanding point of view. As the number of states and transitions increases, the flat model becomes too hard to comprehend. Hierarchical state models can be understood in pieces, each piece being relatively simple to conceive. For example, consider Figure 1.

 

In this model the transition ab leads either of states a1 or a2 to state b; similarly, the transition ac causes the state to change from a1 or a2 to c. The transition toC for all states causes the state to change to c. Transition ba in state a1 results in the new state b. The initial state is b. The state changes from a1 to a2 on transition a1a2, and from a2 to a1 on a2a1. Transition ca leads to a choice point: if the last a state is a1, it leads to a1, otherwise a2.

The hierarchical version of this scenario, depicted in Figure 2, is easier to understand.

 

First, states a1 and a2 are factored out as superstate a (right diagram); the overall picture (left diagram) is cleaner. Transitions ab and ba, from the perspective of the top state, simply shift between states a and b; but in state a we see that ba leads to substate a1, whereas ab originates from a1. The transition ac leads from either a1 or a2 to c; the transition ca leads from c to the last substate of a. In addition, the toC transition no longer needs to originate from each state; to event from the top state's nonextending transition point toC to state c satisfies the intended behavior.

As a consequence of its hierarchical design, ROOM offers two powerful features: group transitions and transitions to history. A group transition is one that occurs for a given state no matter what substate it is in; transition ac leads from state a to c regardless of whether a's substate is a1 or a2. A transition to history is a transition into the most recent substate of a given state; transition ca brings state c to the last substate of a.

Alternative methodologies are UML and Petri-nets, each of which supports hierarchical structures.

Engine
The heart of E-State is a stateless session Enterprise JavaBean (EJB) called StateMachine, which is shaded in the diagram in Figure 3.

 

The StateMachine EJB is configured to point to a particular state model, which is an XML file specifying, for a given application, the following:

  • A set of states and a set of transitions
  • A unique namespace, which enables multiple deployments, as discussed below
  • The name of the Java "action'' callback class that the state machine invokes while processing an event
The EJB applies the model to "actors." An actor, in ROOM methodology, is an "active" object whose behavior is best described with a state model. (In ROOM, an active object also has its own control thread of and its own set of inbound and outbound messaging interfaces. E-State's notion of an actor is more restrictive.) In E-State, an actor is an entity that has state, such as an insurance claim. The transition from one state to another in a model reflects the change in state of the actor; for example, a claim can be waiting, activated, or idle. E-State has three tables that track the state of an actor, namely Actor, Actor_Property, and Actor_State, and has corresponding entity EJBs (Actor, ActorProperty, and ActorState) to represent them, as shown in Figure 3. The StateMachine EJB is in part a facade to these entity EJBs; its actor-management methods include createActor(), getCurrentState(), getChildState(), getActorProperty(), getActorProperties() and setActorProperty().

The remaining methods of StateMachine (startMachine() and injectEvent()) constitute the engine that drives an actor's change of state. Actually, startMachine(), simply calls injectEvent(), passing the special "initial" event type to it, to execute the transitions originating from the initial transition points of each state in the model. The injectEvent() method, then, is the heart of the machine that moves the action of the business process along. This method invokes methods of the user-defined action class along the way, implementing the interface StateAction that is defined with the model. The purpose of the action class is to notify the client of important state machine events and to request logical decisions. The methods of the action class are shown in Table 1.

 

In the insurance example, action classes start workflows to perform task-related or cleanup work, or to start a timer. In WebLogic Integration 7.0, a workflow is started with the BPM API. In WebLogic Integration 8.1, the workflow is called as a Web service.

The methods of the StateMachine EJB are summarized in Table 2.

 

In the insurance example, the injector workflow calls the injectEvent() of the state machine. In WebLogic Integration 7.0, the workflow uses a business operation to call this method. In WebLogic Integration 8.1, it uses an EJB control.

Database Schema
Figure 4 shows the structure of tables to hold persistent actor state information.

 

The main table, Actor, stores the current state of an actor for a particular model type. The current state is the leaf state that the actor is currently in. The primary key is a combination of the actor's unique identifier and its model namespace. An actor can have state in several model namespaces. Notably, if two versions of a model exist with distinct namespaces, the actor's state in each can be represented in the actor table.

The Actor_State table captures the active substate of each composite state of a given actor in a given namespace. This table is for internal use only; the engine uses it to process transitions to history. There is a one-to-many relationship between actor and actor_state.

The Actor_Property table stores user-defined properties for an actor in a given namespace. A property has a name (which is unique per actor per namespace), a type, and a value. This table is provided as a convenience to client applications to associate a set of data with an actor; more likely, that data is held in an application-specific data store.

Deployment
A different instance of the StateMachine EJB is deployed for each state model. The source code is the same for each (same home and remote interfaces, same implementation), but the configuration is different. The deployment descriptor for the EJB specifies a unique Java Naming and Directory Interface (JNDI) name (which clients use to locate EJB), as well as a reference to an XML file containing the model itself. For example, the StateMachine EJB for the insurance state model might have the JNDI name "state_insurance" and point to file "Insurance.xml". To interact with this model, a client application accesses its EJB with the "state-insurance" JNDI name and calls its methods. This peculiar approach has significant advantages:

  • Life cycle: To make a new state model available for processing means to deploy a StateMachine EJB that points to it. To decommission that model means to undeploy that EJB. To promote a change to the model means to redeploy the EJB with the modified model file.
  • Versioning: If an existing state model has a new major version, the new version can be deployed as a separate EJB and coexist with the earlier version. For example, "state-insurance-1.1" can coexist with "state-insurance".
The data model is also conducive to versioning. A given actor can have persistent state for multiple models, including different versions of the same model, as long as the models have distinct names.

Most business processes run for a long time, which makes the management of application upgrades especially challenging. Two scenarios are hard to solve:

  1. A minor patch where there are actors in progress on the unpatched release.
  2. A major patch meant only for new actors; old actors are to continue with the earlier version.
E-State is an intelligent solution to these problems:
  1. Applying the minor patch means redeploying the existing EJB for that model. The actors will pick up where they left off, but with the patch in place.
  2. Applying the major patch means deploying a new EJB with a distinct namespace, but keeping the existing EJB deployed as is. The models are independent, allowing old actors to continue with the earlier release while new actors use the new release.
Conclusion
E-State is an enterprise state machine framework inspired by the ROOM methodology that, when combined with BPM workflows offering key integration services such as systems integration, events, timers, worklist, and XML, provides powerful solutions for development of process-oriented business applications. E-State includes a runtime engine, a schema for state models, persistence services, and user-defined "action" classes, which are invoked by the engine when a transition occurs, or when a state is entered or exited. The action classes likely call workflows to leverage BPM services; workflows, in turn, when triggered by events, call the engine to trigger transitions.

References

  • Selic, Gullickson, and Ward. (1994). Real-Time Object-Oriented Modeling. Wiley.
  • More Stories By Michael Havey

    Michael Havey is a Chordiant consultant with 10 years of industry experience, mostly with application integration. Michael's book Essential Business Process Modeling was published by O'Reilly in August 2005.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    @ThingsExpo Stories
    The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
    Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
    Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
    No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
    With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
    In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
    In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
    Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
    22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
    22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
    DevOps at Cloud Expo – being held June 5-7, 2018, at the Javits Center in New York, NY – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real results. Among the proven benefits,...
    @DevOpsSummit at Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, is co-located with 22nd Cloud Expo | 1st DXWorld Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait...
    Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...
    SYS-CON Events announced today that T-Mobile exhibited at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. As America's Un-carrier, T-Mobile US, Inc., is redefining the way consumers and businesses buy wireless services through leading product and service innovation. The Company's advanced nationwide 4G LTE network delivers outstanding wireless experiences to 67.4 million customers who are unwilling to compromise on qua...
    SYS-CON Events announced today that Cedexis will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Cedexis is the leader in data-driven enterprise global traffic management. Whether optimizing traffic through datacenters, clouds, CDNs, or any combination, Cedexis solutions drive quality and cost-effectiveness. For more information, please visit https://www.cedexis.com.
    SYS-CON Events announced today that Google Cloud has been named “Keynote Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Companies come to Google Cloud to transform their businesses. Google Cloud’s comprehensive portfolio – from infrastructure to apps to devices – helps enterprises innovate faster, scale smarter, stay secure, and do more with data than ever before.
    SYS-CON Events announced today that Vivint to exhibit at SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California. As a leading smart home technology provider, Vivint offers home security, energy management, home automation, local cloud storage, and high-speed Internet solutions to more than one million customers throughout the United States and Canada. The end result is a smart home solution that sav...
    SYS-CON Events announced today that Opsani will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Opsani is the leading provider of deployment automation systems for running and scaling traditional enterprise applications on container infrastructure.
    SYS-CON Events announced today that Nirmata will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Nirmata provides a comprehensive platform, for deploying, operating, and optimizing containerized applications across clouds, powered by Kubernetes. Nirmata empowers enterprise DevOps teams by fully automating the complex operations and management of application containers and its underlying ...
    SYS-CON Events announced today that Opsani to exhibit at SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California. Opsani is creating the next generation of automated continuous deployment tools designed specifically for containers. How is continuous deployment different from continuous integration and continuous delivery? CI/CD tools provide build and test. Continuous Deployment is the means by which...