Skip to content

IBMStockTrader/account

Repository files navigation

This service manages user accounts. The data is backed by a CouchDB-complient document database (Cloudant, CouchDB). The following operations are available:

GET / - gets all accounts.

POST /{owner} - creates a new account for the specified owner.

GET /{owner} - gets details for the specified account.

PUT /{owner}?total={total} - updates the account total for the specified owner (by adding a stock).

DELETE /{owner} - removes the account for the specified owner.

POST /{owner}/feedback - submits feedback (to the Watson Tone Analyzer)

All operations return JSON. An account object contains fields named owner, total, loyalty, balance, commissions, free, sentiment, and nextCommission. The only operation that takes any query params is the PUT operation, which expects a param named total. Also, the feedback operation takes a JSON object in the http body, with a single field named text.

This microservice calls out to three other external services. First, there is a business rule that determines the Loyalty Level of this account. This is called via REST. POSTing feedback also makes a REST call to Watson to determine the sentiment and, potentially, provide free trades depending on the sentiment. Finally, there is a Jakarta Messaging message that is sent when the loyalty level changes. All three of these services are optional.

The code should work with any document-based NoSQL provider that supports the CouchDB API. It has been tested with CouchDB and with Cloudant. The database can either be another pod in the same Kubernetes environment, or in a VM in the cloud, or it can be running on "bare metal" in a traditional on-premises environment. Endpoint and credential info is specified in the Kubernetes secret and made available as environment variables to the application.properties of Quarkus. See the manifests/portfolio-values.yaml for details.

The Jakarta Messaging functionality supports any AMQP 1.0 messaging provider. IBM MQ 9.2.x+ (with AMQP 1.0 support enabled) and Apache ActiveMQ have both been tested.

Build

Build and run Quarkus locally

To build account and run in dev mode, locally, clone this repo and run:

./mvnw quarkus:dev

Build container and push to container registry

./mvnw clean install -Dquarkus.container-image.build=true \
    -Dquarkus.container-image.tag=<your tag> \
    -Dquarkus.container-image.group=ibmstocktrader \
    -Dquarkus.jib.platforms=linux/amd64 \
    -Dquarkus.container-image.registry=<YOUR REGISTRY HOST>

docker push <YOUR REGISTRY HOST AND REPOSITORY>

Run container

In practice this means you'll run something like:

docker run -i --rm -p 9080:9080 <your repository>/account 

About

Account microservice for the IBM Stock Trader sample

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages