Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

swf 4.1 design

Steve Jones edited this page Sep 7, 2017 · 2 revisions

Description

This document covers the implementation related to the SWF Architectural Analysis (ARCH-71, ARCH-82)

Model / Persistence

This section covers the entities and framework used for persistence for SWF elements.

Entities

This diagram shows the SWF entities and their relationships:

Persistence Facades / DAOs

For persistence of each entity there is an interface and associated implementation:

The persistence implementation is provided by a Persistence* class which is annotated with @ComponentNamed so it can be discovered and injected where necessary (the SimpleWorkflowService constructor for example). SwfPersistenceSupport has very limited functionality but specifies the super-types and exceptions for SWF specific AbstractPersistentSupport implementations.

The AbstractPersistentSupport class is not SWF specific, it provides a callback based API for entity persistence and is implemented using existing Entities and Transactions APIs.

Service

This section covers functionality related to the user facing SWF service implementation.

Implementation

The SimpleWorkflowService implements SWF actions. The class is annotated with @ComponentNamed so that dependencies can be injected for persistence and task token management.

Messages and Bindings

Message classes are copied from the AWS SDK for Java. JSON message binding is performed via Jackson. Binding is performed by SimpleWorkflowBinding which implements ExceptionMarshallerHandler in order to respond with JSON format error messages.

For message binding the SwfJsonUtils utility class is used. Jackson is used for for JSON conversion and there is special handling for Dates to use the SWF required date format.

Long Polling

Long polling is used to poll for decision and activity tasks. An internal stateful pollednotifications service is added to implement polling as this cannot easily be implemented directly in the stateless UFS SWF service.

The NotifyClient is implemented using the usual AsyncRequests API. The PolledNotificationService tracks both pollers and pending notifications in memory so it can be responsive. There is also a mechanism for loading existing notifications via PolledNotificationChecker implementations. SWF provides PolledNotificationChecker s for both pending decision and activity tasks.

A limitation of the long polling implementation is that threads are currently blocked while waiting for notifications, this will impact system stability if there are too many clients performing long polling.

Task Tokens

Decision and activity tasks are identified by tokens that are passed back into the service when the task handling is completed. The TaskTokenManager is used for token functionality:

TaskTokenManager handles encryption and decryption of task tokens.

Timeouts

Timeouts for tasks, workflows, timers, and cleanup of deprecated resources are handled by the TimeoutManager .

Whenever a workflow execution or activity task is updated the timeout is calculated. The timeout manager periodically queries for expired timeouts and performs the necessary action(s).

Configuration

Cloud properties for SWF are defined on the SimpleWorkflowProperties class.

Client Framework

Client Configuration and Life Cycle

WorkflowDiscovery and WorkflowRegistry classes detect any activity and workflow implementation classes annotated with @ComponentPart. These detected classes are then used by the Config class, either directly or via the higher level WorkflowClient API. The Config class also handles creating an AWS SDK for Java AmazonSimpleWorkflow that is integrated with our Topology and SecurityTokenManager functionality.

The WorkflowClient exposes start/stop life cycle methods that control the underlying Flow Framework workers.

Workflow Patterns

Generic workflow patterns are implemented in WorkflowUtils . Support is currently limited to asynchronous polling.


tag:confluence tag:rls-4.1 tag:swf




Clone this wiki locally