Expert AWS Development
上QQ阅读APP看书,第一时间看更新

Building and running a project

You can build using the mvn package command. It will generate a swfexample-1.0-SNAPSHOT.jar file in your target directory.

This example contains four different applications. They run independently.

If you are using Windows, you have to execute all applications on different command lines. If you are using Linux, macOS, or Unix, you can execute all applications on the same Terminal window one after another.

You can set the classpath in two ways. One uses the CLASSPATH environment variable to specify the AWS SDK lib and the AWS SDK third-party lib as follows:

export CLASSPATH='target/swfexample-1.0-SNAPSHOT.jar:/aws_sdk_path/lib/*:/aws_sdk_path/third-party/lib/*'
java com.packt.example.Types

Or you can use java -cp option when the application is running:

java -cp target/swfexample-1.0-SNAPSHOT.jar:/aws_sdk_path/lib/*:/aws_sdk_path/third-party/lib/* com.packt.example.Types

You need to register domain, workflow, and activity types before running workers and workflow starters by executing the following commands:

java -cp target/swfexample-1.0-SNAPSHOT.jar com.packt.example.Types

 Once the domain, workflow, and activity type have been registered, you can start the activity and workflow workers:

java -cp target/swfexample-1.0-SNAPSHOT.jar com.packt.example.Activityjava -cp target/swfexample-1.0-SNAPSHOT.jar com.packt.example.Worker

When your workflow and activity workers are polling, you can start the workflow execution.  It will execute until the workflow returns a completed status:

java -cp target/swfexample-1.0-SNAPSHOT.jar com.packt.example.Starter

When you start the workflow execution, you can see the output delivered by both the workers and workflow execution. You will see the output on the screen when the workflow finally completes: