Giter Club home page Giter Club logo

aws-swf-flow-library's Introduction

Releases of aws-swf-flow-library

1.12.x

The 1.12.x release added following changes based on the 1.11.x release:

  • Supported scaling up the number of threads for task polling and task processing independently. This helps to avoid hitting the hard limit of concurrent pollers per task list, as you can increase the task processing threads without increasing the polling threads.
  • Allowed the number of task processing threads to dynamically change between 0 and a configured value. This feature is disabled by default, and you can turn it on by setAllowCoreThreadTimeOut(true) for the workflow/activity workers.
  • Removed the setTaskExecutorThreadPoolSize() and getTaskExecutorThreadPoolSize() methods from GenericActivityWorker and ActivityWorker. To configure the polling thread count and task execution thread count for your activity worker, please use setExecuteThreadCount() and getExecuteThreadCount() instead.
  • Removed the SpringGracefulShutdownActivityWorker and SpringGracefulShutdownWorkflowWorker classes. The SpringActivityWorker and SpringWorkflowWorker have the graceful shutdown logic in themselves.
  • Supported SimpleWorkflowClientConfig for tuning HTTP request timeouts of SWF APIs.
  • Improved the retry policy during worker startup to avoid startup failure due to RegisterActivityType and RegisterWorkflowType throttling.
  • Truncated stack trace to comply with the length limit of the details field in the RespondActivityTaskFailed API. Since the details field has a maximum length of 32768, SWF will return 400s if the original exception has a large stack trace. This change truncates the stack trace in case of detail length exceeded, by preserving the first stack trace element and logging the original stack trace.
  • Upgraded the Jackson dependencies to 2.13.x. We've received customer reports that Jackson upgrade can trigger deserialization error (for certain data types) in their workflows. To make it smooth, you'll need to bump up your workflow type accordingly and let old workflow executions drain out. Essentially you should use the same deployment strategy (e.g., have two fleets running two versions of workflows) as what you do for a workflow logic change.

aws-swf-flow-library's People

Contributors

dependabot[bot] avatar jianchu avatar kongw95 avatar manikandanrs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-swf-flow-library's Issues

Activity times out when activity output exceeds size limit

When an activity output is bigger than activity output size limit then the activity fails but in workflow looks like it's running and ends up in Timed out status when exceeds activity Start To Close Timeout.

It's difficult to find out what is going on so the activity should fail with proper message.

What is the migration path from aws-java-sdk-swf-libraries to aws-swf-flow-library

Sometime in August aws-java-sdk-swf-libraries disappeared, or rather was frozen at 1.11.22, and now https://github.com/aws/aws-swf-flow-library is usually referred to in lieu of aws-java-sdk-swf-libraries, and yet aws-swf-flow-library does not appear to be a complete replacement. Case in point this class is missing: WorkflowWorker. (There maybe others, I didn't do an exhaustive comparison).

So what is the plan? Is it documented anywhere, outside AWS internal/private documentation?

Workflow re-run stops working after some time

From @jharajeev on January 18, 2016 7:6

I just started working on aws swf and have developed a simple workflow using AWS flow framework for JAVA. After I register the workflow, when I try to re-run it, it works fine for some time no matter how many times I try that. But after some time, say few hours, re-run stops working. I checked the history and can see that execution is stuck at DecisionTaskScheduled event and so eventually times out. It seems that activity and workflow workers have stopped running as I can see "No Activities found for the given execution" message in Activities tab of the execution history. It starts working again if I run the workflow and activity host manually.

Am I doing something wrong? For my use case, I need workflow and activity workers to run continuously so that I can trigger the workflow whenever I need from my web application.

4

1
2
3

Copied from original issue: aws/aws-sdk-java#607

@ExponentialRetry is not working

https://docs.aws.amazon.com/amazonswf/latest/awsflowguide/features-retry.html

After following above document for ExponentialRetry, our activities are not retrying automatically as mentioned in the document.
Is there any other thing needed apart from adding @ExponentialRetry on the Activity method.

Below is my Sample code-----

@activities
@ActivityRegistrationOptions(defaultTaskScheduleToStartTimeoutSeconds = 30, defaultTaskStartToCloseTimeoutSeconds = 30)
public interface IMyActivities {

@Activity(name = "PrintHello", version = "24.0")
@ExponentialRetry(
        initialRetryIntervalSeconds = 1,
        exceptionsToRetry = IllegalStateException.class,
        maximumAttempts = 5)
String printHello();

@Activity(name = "PrintBye", version = "18.0")
void printBye(String x);

}

@workflow
@WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 60, defaultTaskStartToCloseTimeoutSeconds = 30)
public interface IWorkflow {

@Execute(name = "DemoWorkflow", version = "11.0")
void start();

@GetState
String getState();

}

@component
@Setter
public class WorkflowServiceImpl implements IWorkflow {
private String state = "Started";

IMyActivitiesClientImpl client = new IMyActivitiesClientImpl();

@Override
public void start() {
    System.out.println("before calling");
    this.handleActivity();
    System.out.println("after calling");
}

@Override
public String getState() {
    System.out.println("state-----" +state);
    return state;
}

private void handleActivity(){
    Promise<String> result = client.printHello();
    client.printBye(result);
}

}

public class MyActivitiesImpl implements IMyActivities {

private boolean check = true;

@Override
public String printHello() {
    System.out.println("In activity 1111");
    if (check) {
        check = false;
        System.out.println("121212121");
       throw new IllegalStateException("showing this for the first time from this activity");
    }
    return "Hello World";
}

@Override
public void printBye(String name) {
    System.out.println("In activity 2222  " + name);
}

}

Source files without license headers

The following source files in the repo does not have license headers:

./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicActivitiesClientImpl.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncTaskInfo.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/TerminateWorkflowExecutionParameters.java

./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/AsyncExecutor.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/AsyncRetryingExecutor.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/AsyncRunnable.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/AsyncScheduledExecutor.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/FixedIntervalInvocationSchedule.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/InvocationSchedule.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/FlowBlockJUnit4ClassRunner.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTestStatement.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/FlowSpringJUnit4ClassRunner.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/CronDecorator.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/CronInvocationSchedule.java
./aws-java-sdk-swf-libraries/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/POJOWorkflowStubImplementationFactory.java

Parent issue: aws/aws-sdk-java#719

build is failing

While building sample project its breaking
BUILD FAILED
Target "build.xml" does not exist in the project "AWS Flow Framework Samples".

Total time: 0 seconds
AwsFlowFramework username$ ant
Buildfile: /Users/username/myproject/mine/aws-swf-flow-library/src/samples/AwsFlowFramework/build.xml

compile:
[mkdir] Created dir: /Users/username/myproject/mine/aws-swf-flow-library/src/samples/AwsFlowFramework/bin
[mkdir] Created dir: /Users/username/myproject/mine/aws-swf-flow-library/src/samples/AwsFlowFramework/tmp
[mkdir] Created dir: /Users/username/myproject/mine/aws-swf-flow-library/src/samples/AwsFlowFramework/bin/classes
[mkdir] Created dir: /Users/username/myproject/mine/aws-swf-flow-library/src/samples/AwsFlowFramework/bin/private/apt_generated
[javac] /Users/username/myproject/mine/aws-swf-flow-library/src/samples/AwsFlowFramework/build.xml:28: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 92 source files to /Users/username/myproject/mine/aws-swf-flow-library/src/samples/AwsFlowFramework/bin/classes

BUILD FAILED
/Users/username/myproject/mine/aws-swf-flow-library/src/samples/AwsFlowFramework/build.xml:28: /Users/username/myproject/mine/aws-swf-flow-library/src/third-party does not exist.

[SWF] POJOActivityImplementation should not try to serialize arbitrary exceptions

From @christophercurrie on February 26, 2015 4:30

When an exception is thrown in an Activity implementation, POJOActivityImplementation attempts to serialize the exception using the current DataConverter. If this fails, however, it throws ActivityFailureException, for which there is no catch block to handle. This results in the exception being logged, but not returned to the Workflow, and the activity ultimately times out.

The reason this is an issue is that exceptions aren't always made to be serialized. As an example, StatementException in the JDBI package provides an accessor to the JDBC connection that triggered the exception; this connection contains a circular reference, which causes the default Jackson serializer used by JsonDataConverter to eventually throw a StackOverflowError.

To fix this, POJOActivityImplementation should only serialize exceptions that it knows will serialize safely, and should instead extract the message (and possibly the stack trace) from any unknown errors that it encounters to be serialized some other way. Otherwise, end users have to defend against this behavior by catching and wrapping problematic exceptions within Activity code, or otherwise live with Activity timeouts.

Copied from original issue: aws/aws-sdk-java#364

Compile?

Has anyone actually gotten this aws swf flow library to compile and run?

[SWF] shutting down an activity worker is a nightmare of exceptions and lost tasks

From @danwashusen on February 25, 2016 5:2

We use SWF to coordinate long running task processing in combination with EC2 auto-scaling and we've noticed a bunch of issues with SpringActivityWorker and the JVM shutdown process.

  1. As far as I can tell with the default functionality (disableServiceShutdownOnStop=false) tasks fail to complete because the 'service' (SWF client) is shut down before 'pollExecutor' and 'poller', as a result tasks can't communicate their results.
  2. Setting disableServiceShutdownOnStop=true seems to fix the task results issue mentioned in 1 but causes other activity tasks to 'timeout' because the poller could still be long-polling. If a task arrives during the shutdown process the JVM locks up trying to submit the task to an executor service that is shutting down.
  3. The 'stop' method on SpringActivityWorker gives no indication (logs, etc) that tasks are being abandoned if they don't complete in terminationTimeoutSeconds (it could check the result of 'awaitTermination').

We've managed to work around issue 3 by overriding the 'stop' method and looping on 'awaitTermination' until it returns true (see below).

Issue 2 seems to be the real kicker; during JVM shutdown spring calls 'stop' on SpringActivityWorker which starts the shutdown process, skipping the 'service' shutdown (as configured) and stopping the 'pollExecutor' and 'poller'. However (as far as I can tell) because the 'service' hasn't been shutdown (which would send an abort to any open requests) its possible for an existing long polling 'pollForActivityTask' request to be running and fetching new tasks. These tasks end up failing with a 'start to close' timeout because they are associated with an instance that was in the process of shutting down.

Maybe I'm missing something obvious because I can't find anyone else complaining about this. We've managed to work around all these issues with the following extension of 'SpringActivityWorker', but honestly the whole shebang makes me anxious.

public class GracefulShutdownSpringActivityWorker extends SpringActivityWorker implements ApplicationListener {
    private final Logger logger = LoggerFactory.getLogger(GracefulShutdownSpringActivityWorker.class);

    public GracefulShutdownSpringActivityWorker() {
    }

    public GracefulShutdownSpringActivityWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll) {
        super(service, domain, taskListToPoll);

        // this value must be true to avoid delayed shutdown issues
        // activities will not be able to report their completed/failed state if the swf client is shutdown...
        setDisableServiceShutdownOnStop(true);
    }

    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        if (event.getClass().equals(ContextClosedEvent.class)) {
            // tell the poller to not fetch any more tasks (this locks up the poller threads)
            logger.info("Suspend polling for new activity tasks...");
            super.suspendPolling();
        }
    }

    /* the default impl. of this method leaves dangling activities that eventually 'time out', this shutdown process ensures that activities complete and report back */
    @Override
    public void stop() {
        if (!isDisableServiceShutdownOnStop()) {
            logger.warn("disableServiceShutdownOnStop is set to false, activities will not be able to report their completed/failed state!");
        }

        // its possible that despite suspending polling we get a task (because it might be currently polling for a task)
        // sleeping for 90 seconds ensures that any tasks accepted before we suspended polling get processed
        sleep();

        // request a shutdown (all running activities should complete)
        logger.info("Stopping the worker...");
        super.stop();

        // now release the suspended polling latch which should now exit because the poller is terminating
        super.resumePolling();

        // wait until all activities complete
        try {
            while (!super.awaitTermination(10, TimeUnit.SECONDS)) {
                logger.info("Still waiting for activity worker to shutdown...");
            }
            logger.info("Done waiting for activity worker to shutdown...");
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new IllegalStateException("Failed while waiting for task executor to complete currently running tasks...", e);
        }
    }

    private void sleep() {
        final Duration duration = Duration.standardSeconds(90);
        logger.info(String.format("Sleeping for %s to allow dangling activity tasks to complete...", duration));
        ThreadUtils.sleepIfYouCan(duration);
    }
}

Copied from original issue: aws/aws-sdk-java#642

files are missing

There are so many class are missing but thats being used in project. I am wondering if its getting compile.
list of missing files
CronWorkflowClientFactory
CronWorkflowSelfClient

Migration to JUnit5

Hi,

I'm currently migrating my test code base to JUnit5 and am stuck on the workflow tests. Is there any plans in the future for a JUnit5 compatible library?

POJOActivityImplementation should not throw ActivityFailureException with details larger than 32k

POJOActivityImplementation.throwActivityFailureException method throws ActivityFailureExceptions but doesn't truncate the "details" constructor param to 32k. This causes AmazonSimpleWorkflowClient.executeRespondActivityTaskFailed to fail:

Caused by: com.amazonaws.services.simpleworkflow.model.AmazonSimpleWorkflowException: 1 validation error detected: Value '...some error payload >32k...' at 'details' failed to satisfy constraint: Member must have length less than or equal to 32768 (Service: AmazonSimpleWorkflow; Status Code: 400; Error Code: ValidationException; Request ID: 741c57e6-e861-42f4-be70-3ab0d1f75761)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1712)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1367)
...
at com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflowClient.respondActivityTaskFailed(AmazonSimpleWorkflowClient.java:3115)
...
at com.amazonaws.services.simpleworkflow.flow.worker.SynchronousActivityTaskPoller.execute(SynchronousActivityTaskPoller.java:211)
...

Notice that the 'reason' parameter is truncated - but not the details param:
com.amazonaws.services.simpleworkflow.flow.pojo.POJOActivityImplementation

void throwActivityFailureException(Throwable exception) 
            throws ActivityFailureException, CancellationException {
        
        if (exception instanceof CancellationException) {
            throw (CancellationException)exception;
        }
        
        String reason = WorkflowExecutionUtils.truncateReason(exception.getMessage());
        String details = null;
        try {
            details = converter.toData(exception);
        } catch (DataConverterException dataConverterException) {
            if (dataConverterException.getCause() == null) {
                dataConverterException.initCause(exception);
            }
            throw dataConverterException;
        }
        
        throw new ActivityFailureException(reason, details);
    }

I suggest truncating 'details' the same way as 'reason':
details = WorkflowExecutionUtils.truncateDetails(converter.toData(exception));

Feel free to assign this to me to fix by pull request... thanks.

SpringActivityWorker.addActivitiesImplementation does not use the DataConverter set in setDataConverter method; uses default instead

(moved from aws/aws-sdk-java#925 issue opened by @jonkerlinger )
When calling setActivitiesImplementation or addActivitiesImplementation on the SpringActivityWorker, the single-arg POJOActivityImplementationFactory.addActivitiesImplementation, which ultimately will only use the default DataConverter or the Activities annotation-specified DataConverter. Even though the POJO implementation of SpringActivityWorker allows users to specify the DataConverter, it is not used when adding ActivitiesImplementations.

To work around it, I've had to extend SpringActivityWorker with something like this:

    @Override
    public List<ActivityType> addActivitiesImplementation(Object activitiesImplementation) {
        try {
            Field field = SpringActivityWorker.class.getDeclaredField("factory");
            field.setAccessible(true);
            POJOActivityImplementationFactory factory = (POJOActivityImplementationFactory) field.get(this);

            return factory.addActivitiesImplementation(activitiesImplementation, factory.getDataConverter());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

The override works fine for now, but is hacky. It seems that since setDataConverter sets the factory DataConverter, then that value should also be passed into the addActivitiesImplementation call, or the POJO factory should use the dataConverter field if present, rather than just looking at the annotation.

[SWF] Implement DecisionTaskPoller.awaitTermination.

From @zstd on January 15, 2015 13:47

Right now method DecisionTaskPoller.awaitTermination not implemented (there is only TODO item) and WorkflowWorker stops without waiting for currently active polling task to complete.

This may lead to sporadical errors in situation when we stop workflow and start it immediately: in that case stopped workflow may 'steal' decision task from starting workflow without ability to process it - that will cause decision task timeout.

Copied from original issue: aws/aws-sdk-java#346

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.