Skip to content

GSA/cm-acr-xsbservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2,620 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot project to call XSB PricePoint APIs (acr-xsb-services)

git clone git@54.145.72.0:/data/repo/cm-acr-xsbservices
cd cm-acr-xsbservices
git remote add mcaas https://github.helix.gsa.gov/ACR/cm-acr-xsbservice.git
git remote -v
git pull --set-upstream mcaas

git clone git@54.145.72.0:/data/repo/cm-acr-futureservice
cd cm-acr-futureservice
git remote add mcaas https://github.helix.gsa.gov/ACR/cm-acr-futureservice.git
git remote -v
git pull --set-upstream mcaas

git clone git@54.145.72.0:/data/repo/cm-acr-dataservice
cd cm-acr-dataservice
git remote add mcaas https://github.helix.gsa.gov/ACR/cm-acr-dataservice.git
git remote -v
git pull --set-upstream mcaas

Clone specific branches

git clone -b development  --single-branch https://github.helix.gsa.gov/ACR/cm-acr-xsbservice.git
git clone -b test  --single-branch https://github.helix.gsa.gov/ACR/cm-acr-xsbservice.git

MCaaS Development S3 bucket name is acr-cm-development-s3

Pushing code to MCaaS

Add remote

git remote add mcaas https://github.helix.gsa.gov/ACR/cm-acr-xsbservice.git


git remote -v
mcaas   https://github.helix.gsa.gov/ACR/cm-acr-xsbservice.git (fetch)
mcaas   https://github.helix.gsa.gov/ACR/cm-acr-xsbservice.git (push)
origin  git@54.145.72.0:/data/repo/cm-acr-xsbservices (fetch)
origin  git@54.145.72.0:/data/repo/cm-acr-xsbservices (push)

List all from remote

git pull --set-upstream mcaas

Checkout a remote branch

git checkout -b development mcaas/development
git checkout -b feature/xsb-updates-001 mcaas/feature/xsb-updates-001

Push to VPC master

git push --set-upstream origin master

Push to mcaas master one time.

git push --set-upstream mcaas master

Push to mcaas branch. MCaaS branch should have prefix feature/

git push --set-upstream mcaas feature/s3-read-write

Now go to https://github.helix.gsa.gov/ACR/cm-acr-xsbservice and create pull request to merge from feature/s3-read-write to development branch.

Now watch the xsbservice kubernetes pod logs on Datadog:

https://app.datadoghq.com/account/login/id/xthpq20frbv3tsm3

Documentation

  • The Google Drive location CM & ACR > XSB has all documentation regarding XSB.
  • This document ACR-XSB Services-Seq Diag details information regarding the service endpoints that is provided by this project.

Build

The following Maven command sets the SpringBootApplication gov.gsa.acr.acrxsbppapi.AcrXsbServicesApp as the main class of the final jar.

mvn package spring-boot:repackage

docker build -t acr/xsb-services.jar:local .
docker image ls
docker rmi <IMAGE ID>
docker run acr/xsb-services.jar

Execution Pre-requisite

In the file KAFKA_HOME/config/consumer.properties set the group id as shown below

group.id=acrxsb

Startup Kafka on workstation

Start Kafka Topics

rmdir /s /q C:\tmp\
cd C:\apps\kafka_2.13-2.7.0\bin\windows
start zookeeper-server-start.bat   C:\apps\kafka_2.13-2.7.0\config\zookeeper.properties

Wait till Zoo Keeper is fully started and then start Kafka as shown below

start kafka-server-start.bat C:\apps\kafka_2.13-2.7.0\config\server.properties

kafka-topics.bat --create --topic xsb-catalog-post            --bootstrap-server localhost:9092
kafka-topics.bat --create --topic xsb-catalog-id              --bootstrap-server localhost:9092
kafka-topics.bat --create --topic xsb-catalog-get             --bootstrap-server localhost:9092
kafka-topics.bat --create --topic xsb-catalog-invalid-records --bootstrap-server localhost:9092

Start a Kafka producer console to enter messages. The gov.gsa.acr.acrxsbppapi.AcrXsbCmdLnRunner will process them.

start kafka-console-producer.bat --topic acr-product-transform  --bootstrap-server localhost:9092
start kafka-console-producer.bat --topic xsb-catalog-post       --bootstrap-server localhost:9092
start kafka-console-producer.bat --topic xsb-catalog-id         --bootstrap-server localhost:9092

Set the following variables before running

In the file KAFKA_HOME/config/consumer.properties set the group id as shown below

group.id=acrxsb

Set the following environment variables

set XSB_PPAPI_USERNAME=ACR
set XSB_PPAPI_PASSWORD="XSB Password provided by Anisa"
set DATASERVICE_HOST_PORT=http://localhost:8080

set KAFKA_TOPIC_XSB_CATALOG_POST=xsb-catalog-post
set KAFKA_TOPIC_XSB_CATALOG_ID=xsb-catalog-id
set KAFKA_TOPIC_XSB_CATALOG_GET=xsb-catalog-get
set KAFKA_TOPIC_XSB_CATALOG_INVALID_RECORDS=xsb-catalog-invalid-records
set KAFKA_TOPIC_LISTEN_INTERVAL_MILLIS=2000

Run the Spring Boot jar

Run the Spring Boot jar or run the docker image as shown in subsequent sections.

java -jar target\xsb-services.jar

Run the docker image

Ensure the following environment variables are saved in file set_env.txt before docker run

XSB_PPAPI_USERNAME='ACR'
XSB_PPAPI_PASSWORD='XSB Password provided by Anisa'
DATASERVICE_HOST_PORT='http://localhost:8080'
KAFKA_TOPIC_XSB_CATALOG_POST='xsb-catalog-post'
KAFKA_TOPIC_XSB_CATALOG_ID='xsb-catalog-id'
KAFKA_TOPIC_XSB_CATALOG_GET='xsb-catalog-get'
KAFKA_TOPIC_XSB_CATALOG_INVALID_RECORDS='xsb-catalog-invalid-records'
KAFKA_TOPIC_LISTEN_INTERVAL_MILLIS=2000

Execue the docker run command with the above environment variables.

docker run --env-file set_env.txt  acr/xsb-services.jar

Confirm that the process is running

docker ps

Shell into to container using CONTAINER ID if requried

docker exec -it 1120d8176a5c  sh

Invoking the services

Get JWT token from Auth Service to be passed to the ACR XSB service.

Get JWT token from DEV

curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' --data '{"username":"acr","password":"pass"}' https://54.145.72.0/auth/getToken --insecure

Get JWT token from Localhost

curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' --data '{"username":"acr","password":"pass"}' http://localhost:8081/auth/getToken 

Invoke ACR XSB services

Example simple REST call on localhost

curl -X GET -H 'Accept: application/json' -u user:pass  http://localhost:8086/acrxsb/catalog-only/95059

To call the service in Dev, add the --insecure option for https

curl -X GET -H 'Accept: application/json' -u user:pass  https://54.145.72.0/xsbservice/acrxsb/catalog/93851 --insecure

Note: The above Basic Auth credentials (user:pass) will be repalced by Authservice Token

Example JSONs

This document by Anisa Price Point API Documentation has example JSON requests and XSB response JSONs

te be deleted

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors