Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions API-Gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ spring:
uri: lb://fund-transfer-service
predicates:
- Path=/fund-transfers/**
httpclient:
connect-timeout: 5000
response-timeout: 10s

management:
endpoints:
web:
exposure:
include: health,metrics,prometheus
metrics:
export:
prometheus:
enabled: true

security:
oauth2:
Expand Down
8 changes: 8 additions & 0 deletions Account-Service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.training.account.service.configuration;

import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableCaching
public class CacheConfig {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.training.account.service.repository;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.training.account.service.model.AccountType;
import org.training.account.service.model.entity.Account;
Expand All @@ -23,6 +24,7 @@ public interface AccountRepository extends JpaRepository<Account, Long> {
* @param accountNumber The account number to search for.
* @return An optional containing the found account, or an empty optional if no account was found.
*/
@Cacheable(value = "accounts", key = "#accountNumber")
Optional<Account> findAccountByAccountNumber(String accountNumber);

/**
Expand All @@ -31,5 +33,6 @@ public interface AccountRepository extends JpaRepository<Account, Long> {
* @param userId the ID of the user
* @return an optional account object
*/
@Cacheable(value = "accounts", key = "'user:' + #userId")
Optional<Account> findAccountByUserId(Long userId);
}
40 changes: 40 additions & 0 deletions Account-Service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ spring:
url: jdbc:mysql://localhost:3306/account_service
username: root
password: root
hikari:
maximum-pool-size: 20
minimum-idle: 5
idle-timeout: 300000
connection-timeout: 20000
max-lifetime: 1200000

jpa:
hibernate:
Expand All @@ -18,6 +24,40 @@ spring:
properties:
hibernate:
format_sql: true
jdbc:
batch_size: 20
order_inserts: true
order_updates: true
batch_versioned_data: true

cache:
type: redis
redis:
time-to-live: 600000

redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
timeout: 2000ms

feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 10000
circuitbreaker:
enabled: true

management:
endpoints:
web:
exposure:
include: health,metrics,prometheus
metrics:
export:
prometheus:
enabled: true

server:
port: 8081
8 changes: 8 additions & 0 deletions Fund-Transfer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.training.fundtransfer.configuration;

import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableCaching
public class CacheConfig {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.training.fundtransfer.repository;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.training.fundtransfer.model.entity.FundTransfer;

Expand All @@ -14,6 +15,7 @@ public interface FundTransferRepository extends JpaRepository<FundTransfer, Long
* @param referenceId the transaction reference ID
* @return an optional fund transfer object
*/
@Cacheable(value = "fundTransfers", key = "'ref:' + #referenceId")
Optional<FundTransfer> findFundTransferByTransactionReference(String referenceId);

/**
Expand All @@ -22,5 +24,6 @@ public interface FundTransferRepository extends JpaRepository<FundTransfer, Long
* @param accountId The ID of the from account.
* @return A list of FundTransfer objects.
*/
@Cacheable(value = "fundTransfers", key = "'account:' + #accountId")
List<FundTransfer> findFundTransferByFromAccount(String accountId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.training.fundtransfer.exception.AccountUpdateException;
import org.training.fundtransfer.exception.GlobalErrorCode;
import org.training.fundtransfer.exception.InsufficientBalance;
Expand Down Expand Up @@ -52,6 +53,7 @@ public class FundTransferServiceImpl implements FundTransferService {
* @throws InsufficientBalance If the required amount to transfer is not available.
*/
@Override
@Transactional
public FundTransferResponse fundTransfer(FundTransferRequest fundTransferRequest) {

Account fromAccount;
Expand Down
44 changes: 41 additions & 3 deletions Fund-Transfer/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,51 @@ spring:
url: jdbc:mysql://localhost:3306/fund_transfer_service
username: root
password: root
hikari:
maximum-pool-size: 20
minimum-idle: 5
idle-timeout: 300000
connection-timeout: 20000
max-lifetime: 1200000

jpa:
hibernate:
ddl-auto: update

show-sql: true

properties:
hibernate:
format_sql: true
format_sql: true
jdbc:
batch_size: 20
order_inserts: true
order_updates: true
batch_versioned_data: true

cache:
type: redis
redis:
time-to-live: 600000

redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
timeout: 2000ms

feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 10000
circuitbreaker:
enabled: true

management:
endpoints:
web:
exposure:
include: health,metrics,prometheus
metrics:
export:
prometheus:
enabled: true
21 changes: 21 additions & 0 deletions Sequence-Generator/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ spring:
url: jdbc:mysql://localhost:3306/sequence_generator
username: root
password: root
hikari:
maximum-pool-size: 20
minimum-idle: 5
idle-timeout: 300000
connection-timeout: 20000
max-lifetime: 1200000

jpa:
hibernate:
Expand All @@ -14,5 +20,20 @@ spring:
properties:
hibernate:
format_sql: true
jdbc:
batch_size: 20
order_inserts: true
order_updates: true
batch_versioned_data: true

management:
endpoints:
web:
exposure:
include: health,metrics,prometheus
metrics:
export:
prometheus:
enabled: true
server:
port: 8083
10 changes: 10 additions & 0 deletions Service-Registry/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ eureka:
spring:
application:
name: SERVICE-REGISTRY

management:
endpoints:
web:
exposure:
include: health,metrics,prometheus
metrics:
export:
prometheus:
enabled: true
8 changes: 8 additions & 0 deletions Transaction-Service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.training.transactions.configuration;

import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableCaching
public class CacheConfig {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.training.transactions.repository;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.training.transactions.model.entity.Transaction;

Expand All @@ -13,6 +14,7 @@ public interface TransactionRepository extends JpaRepository<Transaction, Long>
* @param accountId the ID of the account
* @return a list of transactions
*/
@Cacheable(value = "transactions", key = "'account:' + #accountId")
List<Transaction> findTransactionByAccountId(String accountId);

/**
Expand All @@ -21,5 +23,6 @@ public interface TransactionRepository extends JpaRepository<Transaction, Long>
* @param referenceId The reference ID to match against.
* @return The list of transactions that match the reference ID.
*/
@Cacheable(value = "transactions", key = "'ref:' + #referenceId")
List<Transaction> findTransactionByReferenceId(String referenceId);
}
42 changes: 41 additions & 1 deletion Transaction-Service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ spring:
url: jdbc:mysql://localhost:3306/transaction_service
username: root
password: root
hikari:
maximum-pool-size: 20
minimum-idle: 5
idle-timeout: 300000
connection-timeout: 20000
max-lifetime: 1200000

jpa:
hibernate:
Expand All @@ -17,6 +23,40 @@ spring:
properties:
hibernate:
format_sql: true
jdbc:
batch_size: 20
order_inserts: true
order_updates: true
batch_versioned_data: true

cache:
type: redis
redis:
time-to-live: 600000

redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
timeout: 2000ms

feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 10000
circuitbreaker:
enabled: true

management:
endpoints:
web:
exposure:
include: health,metrics,prometheus
metrics:
export:
prometheus:
enabled: true

server:
port: 8084
port: 8084
Loading