- Clone or download JPA project from https://github.com/jdomainapp/jda.git
- Copy library folder
local-maven-repo
to local Maven repository - Copy JAR Maven lib file
com/thoughtworks/xstream/xstream/1.4.18/xstream-1.4.18.jar
in local Maven repository to foldercom/thoughtworks/xstream/xstream/1.4.11.1
and rename to xstream-1.4.11.1.jar - Run maven complie and install
cd jpa
mvn compile
mvn clean install -DskipTests
- Clone or download OPASys project from https://github.com/jdomainapp/opasys.git
- Run maven complie and install
cd opasys
mvn compile
mvn clean install -DskipTests
- Create a postgresql database
opasys
with user/password: admin/password - Run
db_create.sql
in folderopaysys/src/main/resources
# Start the ZooKeeper service
bin/zookeeper-server-start.sh config/zookeeper.properties
# Start the Kafka broker service
bin/kafka-server-start.sh config/server.properties
# create topics (only run in first time)
bin/kafka-topics.sh --create --partitions 1 --replication-factor 1 --topic userChangeTopic --bootstrap-server localhost:9092
bin/kafka-topics.sh --create --partitions 1 --replication-factor 1 --topic orgAssetChangeTopic --bootstrap-server localhost:9092
- Description: The Spring Cloud Configuration Server (aka Config Server) allows you to set up application properties with environment-specific values. The other services will retrieve its properties from Config Server when the services lanch.
- Run by class
org.jda.example.coursemanmsa.configserver.ConfigurationServerApplication
- Description: Discovery service like Eureka will abstract away the physical location of our services. Eureka can seamlessly add and remove service instances from an environment without impacting the service clients. We use Eureka to look up a service.
- Run by class
org.jda.example.coursemanmsa.eurekaserver.EurekaServerApplication
- Description: A service gateway acts as an intermediary between the service client and an invoked service, pulls apart the path coming in from the service client call and determines what service the service client is trying to invoke. It is a central point to apply rules, policies for requests and responses from/to servcies. The Spring Cloud Gateway allows us to implement custom business logic through filters (pre- and post-filters), it integrates with Netflix’s Eureka Server and can automatically map services registered with Eureka to a route.
- Run by class
org.jda.example.coursemanmsa.gatewayserver.ApiGatewayServerApplication
- Access the directory of each service, run the command:
mvn spring-boot:run
- Manage project information including Project, Activity, Risk, Defect, Issue, User. Activity in
project-service
will be assets in `knowledge asset' when project will be completed. - When a project is created, the user want to get data from the similar completed project,
project-servie
usesopa module
to send requests toopa-service
. Then,opa-service
forward request torisk-service
,knowledge-asset-service
,defect-service
,issue-service
. Theproject-service
also gets the forms and templates of the organization by sending a request to theopa-service
. Similarly,opa-service
sends request toorg-asset-service
- When a project is completed,
project-servie
usesopa module
to sendonComplete event
with all data of the project toopa-service
. Then,opa-service
forward data torisk-service
,knowledge-asset-service
,defect-service
,issue-service
.
- is an intermediary to exchange information between the
project-service
and theasset-services
- Manage forms and templates related to procedures and policies in the organization.
- When procedures and policies are changed, users will create/update/delete org-assets on this service. Then, the service will send kafka events to
opa-service' to update local org-assets in
opa-service`.
- Manage information about Plan, Config, Metric and Finance of a completed project.
- This service exchanges information with
opa-service
.
- Manage information about Risk of a completed project.
- This service exchanges information with
opa-service
.
- Manage information about Defect of a completed project.
- This service exchanges information with
opa-service
.
- Manage information about Issue of a completed project including Isuse, Assignee, Comments.
- This service exchanges information with
opa-service
.
- Manage users of the system.
- When user is changed (add/edit/delete),
security-service
sends kafka event toproject-service
andissue-service
to update their local users.
- Create a Docker container to run the infra services
docker run --network host --name infra-services -it ducmle/jdare:latest bash
- Copy .jar files of the infrastructure services to the
/jda
folder in the container Use thedocker cp
command on the host machine. For example:
CONFIG_SERVER=~/short/opasys/modules/configserver
EUREKA_SERVER=~/short/opasys/modules/eurekaserver
GW_SERVER=~/short/opasys/modules/gatewayserver
docker cp $CONFIG_SERVER/target/configserver-0.0.1-SNAPSHOT.jar infra-services:/jda/configserver.jar
docker cp $EUREKA_SERVER/target/eurekaserver-0.0.1-SNAPSHOT.jar infra-services:/jda/eurekaserver.jar
docker cp $GW_SERVER/target/gatewayserver-0.0.1-SNAPSHOT.jar infra-services:/jda/gatewayserver.jar
- Execute the jar files in this order: config-server => discovery server => gateway server
- From the shell of the Docker container, run the application
.jar
file, using thejava -jar
command.
- From the shell of the Docker container, run the application
java -jar /jda/configserver.jar &
# (wait for it to completely finish...)
sleep 20
java -jar /jda/eurekaserver.jar &
# (wait for it to completely finish...)
sleep 15
java -jar /jda/gatewayserver.jar &
Don't forget the &
symbol at the end as it allows you to run all three commands on the same shell.
- Create a Docker container to run the service
Suppose the service name is address
, whose server port is 8082 and we wish to expose it to the public:
docker run --add-host=inf-server:host-gateway -p 8082:8082 --name address -it ducmle/jdare:latest bash
-
Update the service configuration file to use
inf-server
instead oflocalhost
:- Change in the
.properties
file of the service in the/config
folder of the config server - Change in the the
bootstrap.yml
- Change in the
-
Copy .jar files of the infrastructure services to the
/jda
folder in the container Use thedocker cp
command on the host machine. For example:
docker cp $ADDRESS/target/address-service-0.0.1-SNAPSHOT.jar address:/jda/address-service.jar
- Execute the jar file from the shell of the Docker container using the
java -jar
command.
java -jar /jda/address-service.jar
- To terminate the infrastructure services use the
pkill
command:
pkill -f java
Similar to running a single instance in a Docker container (discussed in the previous section), except that step 1 requires that, for each instance, the service port is mapped to a different host port.
The following commands create two containers running two instances of the service address
. The two containers are named address1
, address2
and their host ports are 7071 and 7072 (respectively).
docker run --add-host=inf-server:host-gateway -p 7071:8082 --name address1 -it ducmle/jdare:latest bash
docker run --add-host=inf-server:host-gateway -p 7072:8082 --name address2 -it ducmle/jdare:latest bash
- If you get the
java.net.UnknownHostException: <some-host-name>
when the service is connecting to the Kafka server then you need to add an entry for172.17.0.1 <some-host-name>
to thehosts
file of the container OS
In folder /opaysys/modules/services
:
- Run Postgres service
docker-compose -f docker-compose-postgres.yml up
- Start Kafka service
docker-compose -f docker-compose-kafka.yml up
In the folder of each service that contains docker compose .yml file:
- Build project
mvn package spring-boot:repackage -DskipTests
- Containerize & start service
- Start service and apply new built code
docker-compose -f docker-compose.yml up --force-recreate --no-deps --build
- Only start service
docker-compose -f docker-compose.yml up
- Start services in this order: config-server => discovery server => gateway server => services
In the folder of each service that contains docker compose .yml file:
- Only stop service
docker-compose -f docker-compose.yml stop
- Stop service and remove container (all data will be removed too)
docker-compose -f docker-compose.yml down