如何使用Amazon SWF [英] How to consume Amazon SWF

查看:150
本文介绍了如何使用Amazon SWF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Amazon SWF 今天启动。



当前的SDK支持似乎并未包含它。我知道它是新的,但是是否有人有很好的资源来使用它,或者我需要在以下任何一个SDK中进行哪些更改才能立即使用?





我个人感兴趣的是Java& PHP SDK的...



可在以下位置查看更新的版本: http:// aws。 amazon.com/releasenotes 谢谢Bjorn!

解决方案

我正在使用Amazon Simple Workflow Service(SWF)实施使用AWS Flow Framework进行异步业务处理。对我而言,使用Maven进行开发构建设置非常重要,这样我就可以轻松地从自己选择​​的IDE(IntelliJ IDEA)进行构建,并自动化测试构建以进行持续集成,并可以进行生产构建以进行发布和部署。



我大部分时间都花在了尝试获取使用AspectJ创建的自动生成的代理类上。当我使用3.7版(Indigo)时,甚至在遵循设置开发环境文档我无法成功将类炸掉。凭直觉,我记得文档中说他们使用了Eclipse 3.6(Helios),因此我下载了此特定版本的Eclipse,并使用加载时编织方法重试,它像冠军一样工作。查看这两个版本之间的Eclipse日志,我发现Eclipse 3.7缺少 log4j freemarker 。因为我是IntelliJ IDEA用户,所以我并没有花太多时间对Eclipse进行进一步的故障排除,但是我敢肯定,使Eclipse正常运行绝对是最有可能的。



我的下一个工作是在我的 pom.xml 中使用最少的信息启动并运行IntelliJ IDEA Maven项目,以启用自动生成代理类。线索是《设置开发环境》文档中有关加载时编织的说明的最后一段,其中指出:


从命令行构建项目,请确保
aws-java-sdk-flow-build-tools-1.3.3.jar在类路径中。此jar
文件包含必须运行
才能生成代码的AWS Flow Framework注释处理器。例如,请参阅示例文件夹中包含
的build.xml文件。


除非我弄错了,否则到目前为止,我所做的研究表明 aspectj-maven-plugin 当前不支持加载时编织。摆脱了进行加载时编织的过程,并结合了 aop.xml 文件和作为Java代理运行的 aspectjweaver ,我转而使用了此插件支持的编译时编织。我忍不住想,当我直接在Eclipse中安装了Java的AWS开发工具包支持时,它又得到了 aws-java-sdk-flow-build-tools-1.3中的支持。 .3.jar 依赖性。借助上述线索,我终于能够通过包含 aws-java-sdk-flow-build-tools-1.3.3.jar pom.xml 中。本条目的其余部分概述了实现所有步骤所采取的步骤。



IntelliJ IDEA项目创建




  1. 启动 IntelliJ IDEA
  2. 创建一个新项目

  3. 输入项目名称,然后项目文件位置

  4. 选择类型应为 Maven模块

  5. 调整任何Maven属性,如果需要,请在下一个屏幕上单击并单击完成

  6. 按照下面的 Maven 说明设置 pom.xml



适用于Java的AWS开发工具包



为了引用开发工作流程和活动的必要类型,您将需要下载适用于Java的AWS开发工具包。建议您使用 Maven 为该库的项目和构建添加依赖项,但仍应下载该库以便获取 aws-java-sdk-flow-build-tools 库,该库位于 lib 目录下。 / p>

SWF流程构建工具



用于Java的 AWS SDK 下载包括<$ lib 目录下的c $ c> aws-java-sdk-flow-build-tools-< version> .jar JAR。为了允许对该库包含Maven 依赖性,您需要将JAR安装到本地的 Maven 存储库中。您可以通过从AWS开发工具包下载的 lib 目录运行以下命令来实现此目的:

  mvn install:安装文件
-Dfile = aws-java-sdk-flow-build-tools-< version> .jar
-DgroupId = com.amazonaws
-DartifactId = aws-java-sdk-flow-build-tools
-Dversion =< version>
-Dpackaging = jar

注意:确保使用您的AWS开发工具包下载中的相应版本替换上述命令中的令牌。



Maven



您的 pom.xml 文件应包含以下依赖项。如果您使用不同的版本遇到了重大更改,我已经提供了正在使用的版本号:

 < dependencies> 
< dependency>
< groupId> org.aspectj< / groupId>
< artifactId> aspectjrt< / artifactId>
< version> 1.6.11< / version>
< / dependency>
< dependency>
< groupId> com.amazonaws< / groupId>
< artifactId> aws-java-sdk-flow-build-tools< / artifactId>
< version> 1.3.3< / version>
< / dependency>
< dependency>
< groupId> com.amazonaws< / groupId>
< artifactId> aws-java-sdk< / artifactId>
< version> 1.3.3< / version>
< / dependency>
< dependency>
< groupId> org.freemarker< / groupId>
< artifactId> freemarker< / artifactId>
< version> 2.3.18< / version>
< / dependency>
< / dependencies>

您的 pom.xml 文件还应包括以下插件。我正在使用源代码包含模式,这些模式遵循我在代码中使用的打包和接口命名约定,尽管您不一定需要这样做:

 < 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>

一旦您包含列出的插件以上并且至少运行过Maven 编译,您应该注意到 aspectj 节点IntelliJ IDEA的 Maven项目工具窗口中的>插件节点。如果需要,还可以可选地添加或调整 aspectj-maven-plugin 插件的配置部分的元素。各种受支持的设置可以在aspectj:compile 目标文档中找到。 -mojo.html rel = noreferrer>此处。我尚未调整插件配置,以确保 .java 文件是在源目录下的正确位置生成的,尽管我确定这是相当不错的。



外部库



一旦包含了个依赖项, / code>并至少运行过Maven 编译,您应该至少注意到在外部库下列出的以下依赖项集


  • com.amazonaws:aws-java-sdk中的 Project 工具窗口中的strong>节点:

    -flow-build-tools

  • com.amazonaws:aws-java-sdk

  • commons-codec:commons-codec

  • commons-logging:commons-logging

  • org.apache.httpcomponents:httpclient

  • org.apache.httpcomponents:httpcore

  • org.aspectj:aspectjrt

  • org.codehaus.jackson:jackson-core-asl

  • org.codehaus .jackson:杰克逊映射器-asl

  • org.freemarker:freemarker



示例pom.xml



 <?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> swf_example< / groupId>
< artifactId> swf_example< / artifactId>
< version> 1.0< / version>

<依赖关系>
< dependency>
< groupId> org.aspectj< / groupId>
< artifactId> aspectjrt< / artifactId>
< version> 1.6.11< / version>
< / dependency>
< dependency>
< groupId> com.amazonaws< / groupId>
< artifactId> aws-java-sdk-flow-build-tools< / artifactId>
< version> 1.3.3< / version>
< / dependency>
< dependency>
< groupId> com.amazonaws< / groupId>
< artifactId> aws-java-sdk< / artifactId>
< version> 1.3.3< / version>
< / dependency>
< dependency>
< groupId> org.freemarker< / groupId>
< artifactId> freemarker< / artifactId>
< version> 2.3.18< / version>
< / dependency>
< / dependencies>

< build>
< plugins>
< 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>
< / build>

< / project>



定义工作流程



定义工作流程您必须创建一个满足以下条件的Java接口:


  1. 该接口使用 @Workflow 进行注释。

  2. 为接口定义了一个方法,该方法用 @Execute 进行了注释,并设置了 version 属性。

  3. 该接口的名称以字符串 Workflow 结尾。

  4. 该接口位于以 workflow

下面是一个名为 MyWorkflow 的示例工作流界面,并将包含一个名为 MyWorkflow.java 的文件,该文件位于源目录 src / main / java 下软件包目录结构 com / some / package / workflow 。我没有包含 @WorkflowRegistrationOptions 批注或其他花哨的提示,因为它们不是必需的,并且取决于您的特定需求:

  package com.some.package.workflow; 

import com.amazonaws.services.simpleworkflow.flow.annotations.Execute;
import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow;

@Workflow
公共接口MyWorkflow {

@Execute(version = 1.0)
void doWorkflow();

}



定义活动



要定义活动,必须创建一个满足以下条件的Java接口:


  1. 该接口用注释@Activities ,并设置了 version 属性。

  2. 该接口的名称以字符串 Activities 结尾。

  3. 该界面位于以工作流/活动结尾的程序包中。

下面是一个名为 MyActivities 的示例活动接口,该接口包含在名为 MyActivities.java ,位于源目录 src / main / java 下,以及包目录结构下的 com / some / package / workflow / activities 。我没有包含 @ActivityRegistrationOptions 批注或其他不必要的注释,因为这些不是必需的,并且取决于您的特定需求:

  package com.some.package.workflow.activities; 

import com.amazonaws.services.simpleworkflow.flow.annotations.Activities;

@Activities(version = 1.0)
公共接口MyActivities {

void doActivity1();
void doActivity2();
void doActivity3();

}



建筑物



为了确保构建过程在日常开发以及非开发环境(例如测试,生产等)中都是相同的,您应该通过在所选的开发工具中运行构建Maven aws-java-sdk aws-java-sdk-flow-build-tools 中包含了各个方面编织到您的工作流和活动中的JAR,以及 aws-java-sdk-flow-build-tools JAR包括必要的机制,该机制可以自动生成所需的代理类,以执行工作流程和活动。为了确保您使用的是最新生成的代理类,在构建之前,请务必清理生成的构件,以丢弃不需要的和/或旧的类。这可以通过在您选择的开发工具中运行以下命令或等效命令来实现:

  mvn clean install 

如果在<$ c中保持启用 showWeaveInfo 配置选项$ c> aspectj-maven-plugin 插件,您应该在构建输出中看到类似以下代码片段的内容,尽管由于只有一个工作流程和一个工作流程,所以这里只有几行输出此运行的活动:

  2012年3月12日下午5:21:22 com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor .AsynchronyDeciderAnnotationProcessor进程
信息:调用了AsynchronyDeciderAnnotationProcessor.process()。
2012年3月12日5:21:22 com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor进程
INFO:正在处理@Activity for MyActivities
2012年3月12日5:21 :22 PM com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor进程
信息:MyWorkflow
的@Workflow处理2012年3月12日5:21:22 com.amazonaws.eclipse.simpleworkflow。 asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor进程
信息:调用了AsynchronyDeciderAnnotationProcessor.process()。



自动生成的代理



在对您的工作流程和活动进行了编译之后,您应该会发现已经创建了以下一系列自动生成的代理类。这些代理将在您的工作流中使用,以调用您的各种活动,在其他工作流中执行子工作流,并在顶层执行工作流。 注意::以下项目符号中的字符串 Workflow和 Activities实际上分别是您实际的工作流程和活动接口的名称,并且您应该看到为该类创建的以下类集每个定义的工作流程和活动接口:




  • 工作流程 Client.java

  • 工作流程 ClientExternal.java

  • 工作流程 ClientExternalFactory.java

  • Workflow ClientExternalFactoryImpl.java

  • Workflow ClientExternalImpl.java

  • Workflow ClientFactory .java

  • 工作流程 ClientFactoryImpl.java

  • 工作流程 ClientImpl.java

  • 工作流程 SelfClient.java

  • 工作流程 SelfClientImpl $ 1.java

  • 工作流程 SelfClientImpl.java

  • 活动 Client.java

  • 活动 ClientImpl.java



我也在包括一些背景信息,以帮助弄清我正在使用的开发环境的类型以及我用于日常编码的工具。



操作系统

  Mac OS X版本10.7.3 

Java

  java版本 1.6.0_29  
Java™SE运行时环境(内部版本1.6.0_29-b11-402-11D50b)
Java HotSpot™64位服务器VM(内部版本20.4-b02-402,混合模式)

Maven

  Apache Maven 3.0.3(r1075438; 2011-02-28 12:31:09-0500)
Maven主页:/ usr / share / maven
Java版本:1.6.0_29,供应商:Apple Inc.
Java主页:/系统/库/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
默认语言环境:en_US,平台编码:MacRoman
操作系统名称: mac os x,版本: 10.7.3 ,拱门: x86_64,家族: mac

IntelliJ IDEA(社区版)

  IntelliJ IDEA 11.0.2 
构建#IC111.277
2月1日构建,2012


Amazon SWF was launched today. How best to consume it with Java / PHP / etc. ?

The current SDK support doesn't appear to include it. I know it's new, but does anyone have any good resources on how to consume it, or what changes I'd need to implement in the any of the following SDK's to get going right away?

Personally, my interest is on the Java & PHP SDK's...

Updated releases are visible at: http://aws.amazon.com/releasenotes Thanks Bjorn!

解决方案

I'm using Amazon Simple Workflow Service (SWF) to implement asynchronous business processing using the AWS Flow Framework. It was important to me to have my development build setup using Maven, so that I could easily build from my IDE of choice (IntelliJ IDEA) as well as automate my test builds for continuous integration and production builds for release and deploy.

Most of my time was spent trying to get the auto-generated proxy classes created using AspectJ. This was initially a problem for me in Eclipse as I was using version 3.7 (Indigo) and even after following both the load-time and compile-time weaving instructions in the Setting up the Development Environment documentation I was unable to successfully get the classes blown out. On a hunch I remembered that the documentation says they used Eclipse 3.6 (Helios), so I downloaded this specific version of Eclipse and retried using the load-time weaving approach and it worked like a champ. Looking at the Eclipse logs between these two versions I was able to see that Eclipse 3.7 is missing a dependency for log4j and freemarker. I didn't bother going too far down the road to troubleshoot this further with Eclipse as I'm more of an IntelliJ IDEA user, but I'm sure that it's most definitely possible to get Eclipse working properly.

My next effort was to get an IntelliJ IDEA Maven project up and running with the minimum amount of information in my pom.xml to enable the auto-generation of the proxy classes. The clue was the last paragraph of the instructions for load-time weaving in the Setting up the Development Environment documentation, which states:

If you are building your project from the command line, ensure that aws-java-sdk-flow-build-tools-1.3.3.jar is in the classpath. This jar file contains the AWS Flow Framework annotation processor that must be run to generate code. For an example, see the build.xml file included in the samples folder.

Unless I'm mistaken, the research I've done to date indicates that the aspectj-maven-plugin doesn't not currently support load-time weaving. Breaking away from doing load-time weaving and utilizing an aop.xml file in conjunction with aspectjweaver running as a Java agent, I moved to compile-time weaving supported by this plugin. I can't help but think that when I installed the AWS SDK for Java support directly in Eclipse that it in turn baked in the support found in the aws-java-sdk-flow-build-tools-1.3.3.jar dependency. Taking the aforementioned clue, I was finally able to get the proxy classes blowing out by including a dependency for aws-java-sdk-flow-build-tools-1.3.3.jar in my pom.xml after installing this JAR into my local Maven repository. The rest of this entry outlines the steps taken to make this all happen.

IntelliJ IDEA Project Creation

  1. Start the IntelliJ IDEA application.
  2. Create a New Project.
  3. Input the Project name and Project files location.
  4. Select type should be Maven Module.
  5. Adjust any Maven properties if appropriate on next screen and click Finish.
  6. Follow the Maven instructions below for setting up the pom.xml.

AWS SDK for Java

In order to reference the necessary types for developing workflows and activities, you will need to download the AWS SDK for Java. It is recommended that you use Maven to include a dependency for this library for your project and build, but you should still download this library in order to get the aws-java-sdk-flow-build-tools library which can be found under the lib directory.

SWF Flow Build Tools

The AWS SDK for Java download includes a aws-java-sdk-flow-build-tools-<version>.jar JAR under the lib directory. In order to allow the inclusion of a Maven dependency for this library, you'll need to install the JAR into your local Maven repository. You can achieve this by running the following from the lib directory of the AWS SDK download:

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 

NOTE: Be sure to replace the tokens in the above command with the appropriate version found in your AWS SDK download.

Maven

Your pom.xml file should include the following dependencies. I've included the version numbers I'm using in case you run into breaking changes using different versions:

<dependencies>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.6.11</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-flow-build-tools</artifactId>
        <version>1.3.3</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>1.3.3</version>
    </dependency>
    <dependency>
        <groupId>org.freemarker</groupId>
        <artifactId>freemarker</artifactId>
        <version>2.3.18</version>
    </dependency>
</dependencies>

Your pom.xml file should also include the following plugin. I'm using source include patterns that following a packaging and interface naming convention I use in my code, though you don't necessarily need to do things this way:

<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>

Once you've include the plugin listed above and have at least run a Maven compile, you should notice an aspectj node appear under the Plugins node within the Maven Projects tool window in IntelliJ IDEA. You can also optional add or tweak the elements of the configuration section of the aspectj-maven-plugin plugin if you desire. The various supported settings can be found in the aspectj:compile goal documentation found here. I've haven't tweaked my plugin configuration yet to ensure that the .java files are generated in the proper location under my source directory, though I'm sure this is quite doable.

External Libraries

Once you've include the set of dependencies listed above and have at least run a Maven compile, you should notice at minimum the following set of dependencies listed under the External Libraries node within the Project tool window in IntelliJ IDEA:

  • com.amazonaws:aws-java-sdk-flow-build-tools
  • com.amazonaws:aws-java-sdk
  • commons-codec:commons-codec
  • commons-logging:commons-logging
  • org.apache.httpcomponents:httpclient
  • org.apache.httpcomponents:httpcore
  • org.aspectj:aspectjrt
  • org.codehaus.jackson:jackson-core-asl
  • org.codehaus.jackson:jackson-mapper-asl
  • org.freemarker:freemarker

Example pom.xml

<?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>swf_example</groupId>
    <artifactId>swf_example</artifactId>
    <version>1.0</version>

    <dependencies>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.6.11</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-flow-build-tools</artifactId>
            <version>1.3.3</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.3.3</version>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.18</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <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>
    </build>

</project>

Defining Workflows

To define a workflow you must create a Java interface that meets the following criteria:

  1. The interface is annotated with @Workflow.
  2. A single method is defined for the interface that is annotated with @Execute and has a version property set.
  3. The interface has a name that ends with the string Workflow.
  4. The interface resides under a package that ends with workflow.

The following is an example workflow interface named MyWorkflow, and would be contained a file named MyWorkflow.java, located under the source directory src/main/java, and under the package directory structure com/some/package/workflow. I haven't included the @WorkflowRegistrationOptions annotation or other bells and whistles as these aren't required and are dependent on your particular needs:

package com.some.package.workflow;

import com.amazonaws.services.simpleworkflow.flow.annotations.Execute;
import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow;

@Workflow
public interface MyWorkflow {

    @Execute(version="1.0")
    void doWorkflow();

}

Defining Activities

To define activities you must create a Java interface that meets the following criteria:

  1. The interface is annotated with @Activities and has a version property set.
  2. The interface has a name that ends with the string Activities.
  3. The interface resides under a package that ends with workflow/activities.

The following is an example activities interface named MyActivities, and would be contained in a file named MyActivities.java, located under the source directory src/main/java, and under the package directory structure com/some/package/workflow/activities. I haven't included the @ActivityRegistrationOptions annotation or other bells and whistles as these aren't required and are dependent on your particular needs:

package com.some.package.workflow.activities;

import com.amazonaws.services.simpleworkflow.flow.annotations.Activities;

@Activities(version="1.0")
public interface MyActivities {

    void doActivity1();
    void doActivity2();
    void doActivity3();

}

Building

In order to ensure that the build process is the same during everyday development as well as for non-development environments (e.g. test, production, etc.), you should run builds in your development tool of choice through Maven. Various aspects have been included in the aws-java-sdk and aws-java-sdk-flow-build-tools JARs which are weaved into your workflows and activities, and the aws-java-sdk-flow-build-tools JAR includes the necessary mechanism to auto-generate the required proxy classes to execute workflows and activities. In order to ensure that you're working with the latest generated proxy classes, you should take care to clean the generated artifacts before a build in order to throw away unneeded and/or old classes. This can be achieved by running the following command or equivalent in your development tool of choice:

mvn clean install

If you keep the showWeaveInfo configuration option enabled in the aspectj-maven-plugin plugin, you should see something like the following snippet in your build output, albeit there are only have a few lines of output here due to only having a single workflow and single activities for this run:

Mar 12, 2012 5:21:22 PM com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor process
INFO: AsynchronyDeciderAnnotationProcessor.process() invoked.
Mar 12, 2012 5:21:22 PM com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor process
INFO: Processing @Activities for MyActivities
Mar 12, 2012 5:21:22 PM com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor process
INFO: Processing @Workflow for MyWorkflow
Mar 12, 2012 5:21:22 PM com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor process
INFO: AsynchronyDeciderAnnotationProcessor.process() invoked.

Auto-Generated Proxies

Once you've compiled your workflows and activities you should find the follow set of auto-generated proxy classes have been created. These proxies are to be used within your workflows to call upon your various activities, execute child workflows within other workflows, and also to execute workflows at a top level. NOTE: The strings "Workflow" and "Activities" in the following bullets would actually be the name of your actual workflow and activities interfaces respectively, and you should see the following set of classes created for each of your defined workflow and activities interfaces:

  • WorkflowClient.java
  • WorkflowClientExternal.java
  • WorkflowClientExternalFactory.java
  • WorkflowClientExternalFactoryImpl.java
  • WorkflowClientExternalImpl.java
  • WorkflowClientFactory.java
  • WorkflowClientFactoryImpl.java
  • WorkflowClientImpl.java
  • WorkflowSelfClient.java
  • WorkflowSelfClientImpl$1.java
  • WorkflowSelfClientImpl.java
  • ActivitiesClient.java
  • ActivitiesClientImpl.java

I'm also including some background information to help clarify the type of development environment I'm working on and tools I'm using for day to day coding.

OS

Mac OS X version 10.7.3

Java

java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11D50b)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)

Maven

Apache Maven 3.0.3 (r1075438; 2011-02-28 12:31:09-0500)
Maven home: /usr/share/maven
Java version: 1.6.0_29, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.7.3", arch: "x86_64", family: "mac"

IntelliJ IDEA (Community Edition)

IntelliJ IDEA 11.0.2
Build #IC111.277
Built on February 1, 2012

这篇关于如何使用Amazon SWF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆