Skip to content

Commit

Permalink
Added a lot
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad45123 committed May 9, 2024
1 parent c1d0b49 commit aa7eb18
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 46 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

build:
mvn -DskipTests package
docker compose build
docker build ./services/jobs --tag ahmad45123/workup:service_jobs
docker build ./services/payments --tag ahmad45123/workup:service_payments
docker build ./services/users --tag ahmad45123/workup:service_users
docker build ./services/contracts --tag ahmad45123/workup:service_contracts

up:
docker compose up --force-recreate
Expand Down
83 changes: 48 additions & 35 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ services:
timeout: 30s
retries: 3
networks:
- microservices
# ports:
# - "5672:5672"
# - "15672:15672"

- default

service_redis:
image: redis:latest
healthcheck:
Expand All @@ -25,7 +22,7 @@ services:
timeout: 30s
retries: 3
networks:
- microservices
- default
# ports:
# - "6379:6379"

Expand All @@ -36,7 +33,22 @@ services:
- jobs_db
- service_mq
networks:
- microservices
- default
- jobs
env_file:
- ./services/jobs/.env

jobs_db:
image: cassandra:4.0.7
volumes:
- ./services/jobs/cassandra-config/cassandra.yaml:/etc/cassandra/cassandra.yaml
healthcheck:
test: [ "CMD", "cqlsh", "-e", "describe keyspaces" ]
interval: 20s
timeout: 10s
retries: 60
networks:
- jobs

# ----- PAYMENTS MICROSERVICE -------
service_payments:
Expand All @@ -46,26 +58,36 @@ services:
- service_mq
- service_redis
networks:
- microservices
- default
- payments
env_file:
- ./services/payments/.env

# ----- PAYMENTS MICROSERVICE -------
payments_db:
image: postgres:latest
environment:
POSTGRES_PASSWORD: payments_password
POSTGRES_USER: payments_user
POSTGRES_DB: payments_database
healthcheck:
test: ["CMD", "pg_isready"]
interval: 20s
timeout: 10s
retries: 10
networks:
- payments

# ----- CONTRACTS MICROSERVICE -------
service_contracts:
image: ahmad45123/workup:service_contracts
depends_on:
- contracts_db
- service_mq
networks:
- microservices

jobs_db:
image: cassandra:4.0.7
volumes:
- ./services/jobs/cassandra-config/cassandra.yaml:/etc/cassandra/cassandra.yaml
healthcheck:
test: [ "CMD", "cqlsh", "-e", "describe keyspaces" ]
interval: 20s
timeout: 10s
retries: 60
- default
- contracts
env_file:
- ./services/contracts/.env

contracts_db:
image: cassandra:4.0.7
Expand All @@ -74,20 +96,11 @@ services:
interval: 20s
timeout: 10s
retries: 60

payments_db:
image: postgres:latest
environment:
POSTGRES_PASSWORD: payments_password
POSTGRES_USER: payments_user
POSTGRES_DB: payments_database

healthcheck:
test: ["CMD", "pg_isready"]
interval: 20s
timeout: 10s
retries: 10
networks:
- contracts

networks:
microservices:
driver: overlay
default:
jobs:
payments:
contracts:
2 changes: 2 additions & 0 deletions services/contracts/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONTRACTS_MQ_URL=service_mq
CONTRACTS_DB_URL=contracts_db:9042
4 changes: 2 additions & 2 deletions services/contracts/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
spring.application.name=contract
spring.rabbitmq.host=localhost
spring.rabbitmq.host=${CONTRACTS_MQ_URL}
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

spring.cassandra.local-datacenter=datacenter1
spring.cassandra.keyspace-name=contracts_data
spring.cassandra.contact-points=localhost:9042
spring.cassandra.contact-points=${CONTRACTS_DB_URL}
spring.cassandra.schema-action=CREATE_IF_NOT_EXISTS


2 changes: 2 additions & 0 deletions services/jobs/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
JOBS_DB_URL=jobs_db:9042
JOBS_MQ_URL=service_mq
8 changes: 4 additions & 4 deletions services/jobs/cassandra-config/cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ seed_provider:
parameters:
# seeds is actually a comma-delimited list of addresses.
# Ex: "<ip1>,<ip2>,<ip3>"
- seeds: "172.18.0.2"
- seeds: "10.0.11.6"

# For workloads with more data than can fit in memory, Cassandra's
# bottleneck will be reads that need to fetch data from
Expand Down Expand Up @@ -663,7 +663,7 @@ ssl_storage_port: 7001
#
# Setting listen_address to 0.0.0.0 is always wrong.
#
listen_address: 172.18.0.2
listen_address: 10.0.11.6

# Set listen_address OR listen_interface, not both. Interfaces must correspond
# to a single address, IP aliasing is not supported.
Expand All @@ -677,7 +677,7 @@ listen_address: 172.18.0.2

# Address to broadcast to other Cassandra nodes
# Leaving this blank will set it to the same value as listen_address
broadcast_address: 172.18.0.2
broadcast_address: 10.0.11.6

# When using multiple physical network interfaces, set this
# to true to listen on broadcast_address in addition to
Expand Down Expand Up @@ -763,7 +763,7 @@ rpc_address: 0.0.0.0
# be set to 0.0.0.0. If left blank, this will be set to the value of
# rpc_address. If rpc_address is set to 0.0.0.0, broadcast_rpc_address must
# be set.
broadcast_rpc_address: 172.18.0.2
broadcast_rpc_address: 10.0.11.6

# enable or disable keepalive on rpc/native connections
rpc_keepalive: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
Expand All @@ -24,4 +25,11 @@ public Queue myQueue() {
public MessageConverter messageConverter() {
return new Jackson2JsonMessageConverter();
}

@Bean
public ApplicationRunner runner() {
return args -> {
System.out.println("WE ARE NEW IN JOBS");
};
}
}
4 changes: 2 additions & 2 deletions services/jobs/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
spring.rabbitmq.host=service_mq
spring.rabbitmq.host=${JOBS_MQ_URL}
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest


spring.cassandra.local-datacenter=datacenter1
spring.cassandra.keyspace-name=jobs_data
spring.cassandra.contact-points=jobs_db:9042
spring.cassandra.contact-points=${JOBS_DB_URL}
spring.cassandra.schema-action=CREATE_IF_NOT_EXISTS
2 changes: 2 additions & 0 deletions services/payments/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PAYMENTS_DB_URL=jdbc:postgresql://payments_db:5432/payments_database
PAYMENTS_MQ_URL=service_mq
4 changes: 2 additions & 2 deletions services/payments/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spring.application.name=payments
spring.datasource.url=jdbc:postgresql://localhost:5432/payments_database
spring.datasource.url=${PAYMENTS_DB_URL}
spring.datasource.username=payments_user
spring.datasource.password=payments_password
spring.jpa.hibernate.ddl-auto=create-drop
Expand All @@ -8,7 +8,7 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.format_sql=true
server.error.include-message=always

spring.rabbitmq.host=service_mq
spring.rabbitmq.host=${PAYMENTS_MQ_URL}
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
Expand Down

0 comments on commit aa7eb18

Please sign in to comment.