Домой United States USA — software Spinning Your Workflows With Cadence

Spinning Your Workflows With Cadence

172
0
ПОДЕЛИТЬСЯ

Learn all about Cadence, an open-source workflow engine created by Uber and based on the AWS SWF (Simple Workflow Service). It uses Apache Cassandra (and other databases) for persistence and is designed to be highly fault-tolerant and scalable.
Join the DZone community and get the full member experience. (Source: Shutterstock) Pedaling with a high Cadence (pedal revolutions) is called Spinning; Mashing or Grinding is slow (and bad). Over the last decade, the rapid rise in Big Data use cases has accelerated popular massively scalable open sources technologies such as Apache Cassandra® for storage, Apache Kafka® for streaming, and OpenSearch® for search. In addition, there’s a new member of the peloton, Cadence, for workflow orchestration. My flatmate used to carry his Cello on a bike to music lessons, a bit like this, but music and cycling also have something more in common—Cadence! (Source: Adobe Stock) In music, a Cadence is a musical phrase that sounds complete. And in cycling, Cadence is how fast the cyclist pedals, which influences efficiency and speed. Workflow orchestration is the process of defining and executing a series of tasks and the order they are to be carried out. For example, you may want some tasks to be performed in sequence, but others may be performed concurrently. You also see this idea in orchestral music scores, such as in this example, which provides the conductor, musicians, and choir instructions on what notes to play and when. By Max Reger—IMSLP, Public Domain, (https://commons.wikimedia.org/w/index.php?curid=51020706) In typical workflow terminology (e.g., BPMN), a workflow has start and end events, activities (atomic or compound tasks), gateways (decisions), and sequences or flows—the order of activities in a workflow. In bygone eras of computing, I’ve experienced previous attempts to implement and model workflows, including Enterprise Java Beans (Stateful Session Beans were used for workflows), ebXML, BPEL, and modeling evaluating workflows using discrete event simulation. Traditional workflow modeling uses the semantics of semi/formal notations, including Finite State Machines (FSM), Markov Models, discrete event simulation, and Petri networks to specify, visualize, and analyze workflows. Open source Cadence was developed by Uber and based on the AWS SWF (Simple Workflow Service). It uses Apache Cassandra (and other databases) for persistence and is designed to be highly fault-tolerant and scalable. Perhaps the most surprising feature of Cadence, compared to different workflow engine approaches I’ve encountered previously, is that it is focused on helping developers write workflows primarily either in Java or Go (other languages are available) and therefore doesn’t come with any visualization notation or tool to specify workflows. Instead, the semantics are just plain old code. However, it does have the ability (with the Cadence Web client) to visualize workflows as they execute. (Source: Shutterstock) Now, riding a bike needs a lot of gear. For example, you need a bike (logically), helmet, shoes, water bottle, glasses, gloves, a light, pump, lycra (optional!), etc. Likewise, successful use of Cadence needs many things, including workflows, activities, domains, workflow clients, and workers. Let’s take a look at each in turn. Factory workflows require a strict ordering of tasks (Source: Shutterstock) Let’s start with the most basic Cadence concept, workflows. I’ll be using the cadence java client, which requires you to download it and configure it to compile in your IDE of choice (I use Eclipse and Maven, and for simplicity, I’ve omitted the imports). There are a bunch of java client examples that inspired mine. But, first, we need a workflow interface and implementation. Workflow interface: Workflow implementation: There’s always precisely one method in Cadence with the @WorkflowMethod annotation, which acts as the start event for the workflow and contains the sequence flow and activities. Calling it starts a stateful workflow instance, which eventually ends.

Continue reading...