IntelliJ: AWS Flow Framework (SWF)

AWS Flow Framework is a hidden gem; am highly recommending to use it for anybody that does any sort of distributed computations (probably saved me from months of coding; and as always scaling and maintenance is a breeze with AWS).

Officially it is recommended to use Eclipse for the AWS-SWF.  However, it is quite easy to get it running under IntelliJ.  IntelliJ actually takes a lot less time to set up than for eclipse (p.s. I am using the ultimate version; so some things might be different for the community ver).

I have created two seed projects on GitHub; (1) plain HelloWorld, (2) HelloWorld with Spring (recommended).

Note: you still need to take several steps bellow to get it working.

Setup

Installing aws-java-sdk-flow-build-tools

Note that aws-java-sdk-flow-build-tools is not yet hosted in maven repository; so you would need to install it locally.  You’ll need to download aws-java-sdk.  aws-java-sdk-flow-build-tools-<version>.jar will be in the lib folder.  Finally to install it to local maven repository execute:

mvn install:install-file \
    -Dfile=aws-java-sdk-flow-build-tools-<version>.jar \
    -DgroupId=com.amazonaws \
    -DartifactId=aws-java-sdk-flow-build-tools \
    -Dversion=<version> \
    -Dpackaging=jar

Maven

The project is based on Maven; so sure you have it installed;  p.s. on osx you will need to instal maven “brew install maven”.

Configuration

Finally you need to do some minor config; choose either Spring or Plain (depending on which seed project you are using on github (spring is recommended).

Spring

Change domain in AppConfig (you might have clashes with existing “Samples” domain’s version of activities; so just make a new domain)

Put needed values in aws.properties

Run: maven test

Sometime an exception is thrown with regards to connection pool (I think it is due to terminating the service; without waiting sufficiently long).
`java.lang.IllegalStateException: Connection pool shut down`

TroubleShooting:

Problem: com.amazonaws.AmazonServiceException: Status Code: 400, AWS Service: AmazonSimpleWorkflow, AWS Request ID: 6ee6b605-8661-11e3-88a2-a5ccaae822cf, AWS Error Code: UnrecognizedClientException, AWS Error Message: The security token included in the request is invalid.
Solution: fill in aws.properties

Plain

target/generated-sources did not seem to be generated by executing compile; it does get generated once you actually run of your files (e.g. ActivityHost)

fill in values for access.properties and set environment variable in “~/.bash_profile” add “export AWS_SWF_SAMPLES_CONFIG=PATH_TO_DIR_containing_access.properties”
and follow instructions in aws-sdk-java-master/src/samples/AwsFlowFramework/README.html.

Additional Description

Bellow is a brief description of the modifications done to the official HelloWorld project (most of them are already in the github).

To get started you may want to get the official HelloWorld (this file, partially taken from aws samples) working first.  p.s. you need to include commons package; and

It does work with Community edition of IntelliJ; but seems to work smoother with the ultimate edition which has ApsectJ plugin.

 

Various

Important Details

References

This great post that gets the aspectj weaving going)

Spring version based in part on this post.

 

 

 

 

 

OLD (archival)

keywords: amazon simple workflow framework intellij idea eclipse aws

 

for a more update pom.xml see github instead (spring’s version is better); included for archiving purposes:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>aiconductor-client-logic</groupId>
    <artifactId>aiconductor-client-logic</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- adopted from https://github.com/aws/aws-sdk-java/blob/master/pom.xml -->

    <properties>
        <jackson.version>1.8.9</jackson.version>
        <spring.version>3.0.7.RELEASE</spring.version>
    </properties>

    <dependencies>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.2</version>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.3</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>${jackson.version}</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>${jackson.version}</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

    <!-- The Amazon Simple Workflow Java Flow framework
         requires additional dependencies -->
    <dependency>
        <groupId>org.freemarker</groupId>
        <artifactId>freemarker</artifactId>
        <version>2.3.9</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${spring.version}</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.6.0</version>
        <optional>true</optional>
    </dependency>

        <!-- JUnit is needed to compile the support classes for the workflow service -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <optional>true</optional>
        </dependency>

        <!-- NR: mods for enabling aspectj weaving etc.; ref: http://stackoverflow.com/questions/9392655/how-to-consume-amazon-swf/ -->
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-flow-build-tools</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <!-- NR: mods for enabling aspectj weaving etc. -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>aspectj-maven-plugin</artifactId>
                    <version>1.4</version>
                    <configuration>
                        <complianceLevel>1.5</complianceLevel>
                        <showWeaveInfo>true</showWeaveInfo>
                        <verbose>true</verbose>
                        <!--
                                            <sources>
                                                <source>
                                                    <basedir>src/main/java</basedir>
                                                    <includes>
                                                        <include>*/**/workflow/*Workflow.java</include>
                                                        <include>*/**/workflow/activities/*Activities.java</include>
                                                    </includes>
                                                </source>
                                            </sources>
                        -->
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                                <goal>test-compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </pluginManagement>

    </build>

</project>

 

 

 

About Neil Rubens

see http://ActiveIntelligence.org
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to IntelliJ: AWS Flow Framework (SWF)

  1. Pingback: Hosting Maven Repository for third-party jars on Git (Bitbucket/Github) | Active Intelligence

Leave a Reply

Your email address will not be published. Required fields are marked *


*