-
Notifications
You must be signed in to change notification settings - Fork 35
Build and run examples
Use the steps described here to build and run the Trooper examples:
Certain Trooper profiles like the Orchestration profile depends on 3rd party libraries like Mule and RabbitMQ. Transitive dependencies from these libraries are available in different Maven repositories. It is therefore advisable to create/use a Maven users setting.xml. A sample with relevant public repositories is available here : Maven user settings (Note: The artifactory settings may need to be suitably modified if you have a local instance or removed altogether if your build relies entirely on public repositories.)
Trooper uses RabbitMQ 2.8.x that in turn requires the Erlang R15B01 runtime. These may be downloaded from:
- Erlang : Erlang download
- RabbitMQ : RabbitMQ 2.8.5 download
(Use this guide if you don't want to checkout the whole source and just want a quick way to get started with Trooper Batch or Service (SEDA) profile. Skip this section if you want to checkout the whole source and build them)
-
Clone (or Download) all projects in: (https://github.com/regunathb/Trooper/tree/master/examples)
-
(Optional) Import them as projects in your IDE
-
Now cd to the corresponding example project. ('example-batch' for Batch Profile, 'example-seda' for Service Framework). For batch:
cd example-batch
-
mvn clean install
-
You can optionally use:
mvn eclipse:eclipse
ormvn idea:idea
(depending on your IDE) to resolve the dependencies and create your project file -
To run the batch profile, create a Run Configuration. The project/module name should be: 'example-batch'. Main class should be: "org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher". As an argument pass it absolute path to bootstrap.xml (This is present in example-batch/src/main/resources/external)
-
To run the service profile, create a Run Configuration. The project/module name should be: 'example-seda'. Main class should be: "org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher". As an argument pass it absolute path to bootstrap.xml (This is present in example-seda/src/main/resources/external)
-
You should see the Console running at: localhost:8182 (for batch profile) or localhost:8184 (for service profile)
-
You can modify the example projects or create your own projects (using example projects as a template)
The Orchestration profile example depends on a number of other Trooper projects. All dependencies are listed in the project's pom file. An easy-to-use build file that builds all dependencies is available as:
examples/pom-examples-seda-with-dep.xml
Use this pom file to build as follows:
cd examples
mvn clean install -f ./pom-examples-seda-with-dep.xml
This extract from the Maven Reactor build order lists dependencies among various modules. A description has been added for each of the modules to explain their purpose:
[INFO] Reactor Build Order:
[INFO]
[INFO] Platform Model - Model project containing common XSD files used across profiles
[INFO] Platform Core - Libraries project containing common APIs and their implementations
[INFO] Platform Task - The Task framework project. APIs mostly with some implementation
[INFO] Platform Integration - Integration APIs project, may also have some implementations
[INFO] Platform Runtime Core - Project that brings up the Trooper runtime
[INFO] Service Model - Model project containing common XSD files for Service Profile
[INFO] Service Framework Core - Service Framework core APIs and implementation project
[INFO] RabbitMQ Mule Transport - RabbitMQ 2.x based trasport aka connector for Mule 2.x
[INFO] SEDA Service Framework - The Orchestration Profile implementation
[INFO] Example Models - Model project containing XSD files for all examples
[INFO] Example Services - Service Profile based project for example services
[INFO] RabbitMQ Integration - RabbitMQ based implementation for some Platform Integration APIs
[INFO] Example Orchestration - Orchestration profile based project using Example Services
[INFO] Trooper Examples - Umbrella project for building Trooper Orchestration examples
The Batch profile example depends on a number of other Trooper projects. All dependencies are listed in the project's pom file. An easy-to-use build file that builds all dependencies is available as:
examples/pom-examples-batch-with-dep.xml
Use this pom file to build as follows:
cd examples
mvn clean install -f ./pom-examples-batch-with-dep.xml
This extract from the Maven Reactor build order lists dependencies among various modules. A description has been added for each of the modules to explain their purpose:
[INFO] Reactor Build Order:
[INFO]
[INFO] Platform Model - Model project containing common XSD files used across profiles
[INFO] Platform Core - Libraries project containing common APIs and their implementations
[INFO] Platform Integration - Integration APIs project, may also have some implementations
[INFO] Platform Runtime Core - Project that brings up the Trooper runtime
[INFO] Batch Model - Model project containing common XSD files for Batch Profile
[INFO] Batch Core - Batch Framework core APIs and implementation project
[INFO] Example Models - Model project containing XSD files for all examples
[INFO] RabbitMQ Integration - RabbitMQ based implementation for some Platform Integration APIs
[INFO] Example Batch - Batch profile based project using Example Jobs
[INFO] Trooper Batch Examples - Umbrella project for building Trooper Batch examples
Each of the Trooper profile examples may be run as described below:
Run the org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher
class from the runtime-core
module by specifying path to the Trooper bootstrap configuration i.e. bootstrap.xml
after setting relevant classpath for the runtime-core
project. In the Eclipse IDE, the classpath may be easily generated by executing:
cd runtime-core
mvn eclipse:eclipse
A console based invocation of the sample might look like:
java -cp "<runtime-core classpath>:<any slf4j binding jars>" org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher Trooper/runtime-core/src/test/resources/external/bootstrap.xml
A successful execution will print the following on console:
*************************************************************************
Trooper __
__/ \ Runtime Nature : STANDALONE
__/ \__/ Component Container : None
/ \__/ \ Startup Time : 583 ms
\__/ \__/ Host Name: RegusMacBookPro.local
\__/
*************************************************************************
Notice here that this is a vanilla runtime and does not load any "component container" and is just the Basic profile.
JMX administration of the runtime is available via an MBean that can be accessed via any MBean inspector like JConsole or JVisualVM and navigated to like :
spring.application --> Trooper --> Runtime --> Bootstrap-Test Runtime
The Basic profile is best suited to build out any custom profile on Trooper that best suits an application or a class of application workloads.
Run the org.trpr.platform.servicefw.client.StandAloneServiceClient
class from the serviceframework-core
module by specifying path to the Trooper bootstrap configuration i.e. bootstrap.xml
, the service name, request-response classes and the request input file after setting relevant classpath for the example-services
project. In the Eclipse IDE, the classpath may be easily generated by executing:
cd example-services
mvn eclipse:eclipse
A console based invocation of the sample might look like:
java -cp <example-services classpath> org.trpr.platform.servicefw.client.StandAloneServiceClient
Trooper/examples/example-services/src/main/resources/external/bootstrap.xml greetingService
org.trpr.example.model.service.greetingservice.GreetingServiceRequestXML
org.trpr.example.model.service.greetingservice.GreetingServiceResponseXML Trooper/examples/example-services/src/test/resources/external/GreetingServiceRequest.xml
A successful execution will print the following on console:
*************************************************************************
Trooper __
__/ \ Runtime Nature : STANDALONE
__/ \__/ Component Container : org.trpr.platform.servicefw.impl.spring.SpringServicesContainer
/ \__/ \ Startup Time : 1,141 ms
\__/ \__/ Host Name: RegusMacBookPro.local
\__/
*************************************************************************
This runtime uses a "Spring Services" container as the component container and therefore builds up a Service profile on capabilities of the Basic profile described above.
The "Standalone service client" class used in this test launches the Service profile Trooper runtime and executes "GreetingService version 1.0" using the service request specified as runtime arguments. It also opens up the XML-serialized version of the service response in a suitable editor for viewing. It then shuts down the Service profile runtime.
Replace GreetingServiceRequest.xml
with GreetingServiceRequest.json
in the input for JSON request-response processing.
Sample requests are available here:
Additionally, the console trace logs output from the "GreetingService version 1.0" that was executed.
The Orchestration profile uses Mule 2.x to chain the example services and RabbitMQ 2.x as the messaging layer. Make sure that a RabbitMQ 2.x server/broker is running locally when running this test. Note that the Orchestration profile waits until a RabbitMQ connection is available locally and starts up successfully only on successful connect.
Run the org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher
class from the runtime-core
module by specifying path to the Trooper bootstrap configuration i.e. bootstrap.xml
after setting relevant classpath for the example-seda
project. In the Eclipse IDE, the classpath may be easily generated by executing:
cd example-seda
mvn eclipse:eclipse
A console based invocation of the sample might look like:
java -Dlog4j.configuration=file:<absolute path to log4j.properties> -cp "./target/*:./target/lib/*" org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher ./src/main/resources/external/bootstrap.xml
A successful execution will print the following on console:
**********************************************************************
* Mule ESB and Integration Platform *
* Version: 2.2.1 Build: 14422 *
* MuleSource, Inc. *
* For more information go to http://mule.mulesource.org *
* *
* Server started: 8/27/12 6:27 PM *
* Server ID: b77dd6f5-f046-11e1-b8ee-07cf6ca0ca7c *
* JDK: 1.6.0_33 (mixed mode) *
* OS encoding: MacRoman, Mule encoding: UTF-8 *
* OS: Mac OS X (10.7.4, x86_64) *
* Host: RegusMacBookPro.local (000.00.00.00) *
* *
* Agents Running: None *
**********************************************************************
18:27:12.763 [main] INFO o.t.p.r.i.bootstrap.spring.Bootstrap -
*************************************************************************
Trooper __
__/ \ Runtime Nature : STANDALONE
__/ \__/ Component Container : org.trpr.platform.seda.impl.service.MuleServicesContainer
/ \__/ \ Startup Time : 2,712 ms
\__/ \__/ Host Name: RegusMacBookPro.local
\__/
*************************************************************************
This runtime uses a "Mule Services" container as the component container and therefore builds up an Orchestration profile on capabilities of the Service profile described above.
The Orchestration profile chains the "GreetingService" response to the "EchoService" as defined in Trooper/examples/example-seda/src/main/resources/external/mule-config.xml
. The Mule model is now ready for execution and may be triggered by publishing messages to RabbitMQ.
Run the org.trpr.example.seda.client.SedaClient
from the example-seda
module after setting relevant classpath for the example-seda
project. In the Eclipse IDE, the classpath may be easily generated by executing:
cd example-seda
mvn eclipse:eclipse
A console based invocation of the sample might look like:
java -cp <example-seda classpath> org.trpr.example.seda.client.SedaClient
The Seda client publishes 1000 messages each from 10 threads. Each message is an instance of the Earthling
Java type.
The console of the Orchestration profile runtime JVM displays logs from the execution of Greeting service and the Echo service.
The Orchestration profile exposes an additional JMX MBean for collecting service invocation statistics and may be navigated to like :
spring.application --> Trooper --> Service-Statistics --> ServiceStatisticsGatherer-Test_Runtime
Testing using cron triggers :
The Batch profile uses Spring batch as the job framework which in turn uses Quartz for job triggering.
Run the org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher
class from the runtime-core
module by specifying path to the Trooper bootstrap configuration i.e. bootstrap.xml
after setting relevant classpath for the example-batch
project. In the Eclipse IDE, the classpath may be easily generated by executing:
cd example-batch
mvn eclipse:eclipse
A console based invocation of the sample might look like:
java -Dlog4j.configuration=file:<absolute path to log4j.properties> -cp "./target/*:./target/lib/*" org.trpr.platform.runtime.impl.bootstrap.BootstrapLauncher ./src/main/resources/external/bootstrap.xml
A successful execution will print the following on console:
*************************************************************************
Trooper __
__/ \ Runtime Nature : STANDALONE
__/ \__/ Component Container : org.trpr.platform.batch.impl.spring.SpringBatchComponentContainer
/ \__/ \ Startup Time : 1,851 ms
\__/ \__/ Host Name: RegusMacBookPro.local
\__/
*************************************************************************
Testing without cron triggers :
There is often a need to test batch jobs without using the cron triggers, say during development and unit testing. This can be achieved using the "Stand alone batch client". Run the org.trpr.platform.batch.client.StandAloneBatchClient
class from the batch-core
module by specifying path to the Trooper bootstrap configuration i.e. bootstrap.xml
and the job name after setting relevant classpath for the example-batch
project. In the Eclipse IDE, the classpath may be easily generated by executing:
cd example-batch
mvn eclipse:eclipse
A console based invocation of the sample might look like:
java -cp <example-batch classpath> org.trpr.platform.batch.client.StandAloneBatchClient Trooper/examples/example-batch/src/main/resources/external/bootstrap.xml shellTaskletsJob
The "Standalone batch client" class used in this test launches the Batch profile Trooper runtime and executes "shellTaskletsJob" and its output can be viewed on the console.
This runtime uses a "Batch component container" as the component container and locates and loads individual batch job definitions.
The "Greeting Job" sample demonstrates reading, processing and writing(publishing to a queue) a number of Earthling
instances. The job employs the following parallel processing features:
- Partitioning - uses a grid size of 1 to demonstrate how batch jobs may partition input data on a per instance basis
- Chunking - demonstrates reading and processing data in chunks before being written out.
The console of the Batch profile runtime JVM displays logs from the execution of Greeting job writer. Refer to the reader, processor and writer Java sources of the Greeting job for behavior details.
The Batch profile exposes additional JMX MBeans for collecting batch execution statistics and interactive job execution and may be navigated to like :
spring.application --> Trooper --> Batch-Management --> JobAdministrator-Test_Runtime
and
spring.application --> Trooper --> Batch-Management --> BatchExecutionMetrics-Test_Runtime