Skip to content

carrot-garden/osgi_paremus-examples

Repository files navigation

Overview:

This example shows a simple pricing gateway set up that demonstrates the following:

* A trivial implementation of a gateway with command line client,
backend pricing engine and asynchronous gateway listeners.

* The gateway and the pricing engine are written in Scala for its
async behaviours and use OSGi declarative services as the component
model.

* There is a simple blueprint persistence gateway listener written in
Java that takes quotes/requests and writes them to disk

* The command line is a Java OSGi bundle

* The remote communications are pluggable via RSA but the demo will
default to using SLP for discovery and EssenceRMI for the transport.

* Systems and repositories used to deploy the components on the fabric.

Source:

The source is split up into the following directories:

* gateway.api - shared Java api for components
* gateway.persistence - blueprint persistence component
* gateway.cli - simple osgi shell
* gateway.pricer - scala pricing engine using declarative services
* gateway.scripts - scripts to launch components in nimble
* gateway.system - systems to deploy components in fabric

Build:

All the dependencies are packaged with this example so just run ant from the top level gateway directory

$ cd $examples
$ ant -f gateway.build/build.xml

Single JVM:

The following example shows how to setup the components so that they run in a single framework with
no remote communication. First launch posh in the gateway example directory.

$ $fabric/bin/posh

Now build the repositories that nimble will use to install the artifacts

% sh gateway.scripts/repos/makeRepos.osh
% sh gateway.scripts/repos/loadRepos.osh

Install the parts of the example, note that Nimble will download the dependencies from the repository.

% nim add osgi.active.bundle/gateway.cli
% nim add msf/com.example.gateway id=foo
% nim add msf/com.example.pricer#f type=firm
% nim add msf/com.example.pricer#i type=indicative

Now use the gateway cli to connect and request some quotes

% gateway login demo
% gateway request paremus ibm oracle microsoft yahoo
% gateway testbatch --batchSize=10000 --batchCount=10 --requestTimeout=60000

Multi JVM:

This example launches several nimble instances and installs components in each
using slp and essence rmi for the remote discovery/communication

$0 $fabric/bin/posh
$1 $fabric/bin/posh
$2 $fabric/bin/posh

%0 sh gateway.scripts/services/client.osh
%1 sh gateway.scripts/services/impl.osh
%2 sh gateway.scripts/services/pricer.osh

Now use the gateway cli to connect and request some quotes

%0 gateway testbatch --batchSize=10000 --batchCount=10 --requestTimeout=60000

Fabric:

The final example is to deploy these components via the service fabric using a system document.

First launch a number of fibres with one providing the infrastructure services.

$0 $fabric/bin/posh
$1 $fabric/bin/posh -kc fibre --type=infra
$n $fabric/bin/posh -kc fibre

Now connect to the infrastructure fibre and import/deploy the gateway system.

%0 fabric connect localhost:9101
%0 sh gateway.scripts/systems/gateway.osh
%0 fabric status -S gateway.system

Now use the gateway cli to connect and request some quotes

%0 sh gateway.scripts/services/client.osh
%0 gateway testbatch --batchSize=10000 --batchCount=10 --requestTimeout=60000

About

Example applications developed by Paremus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published