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
29 changes: 29 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### Deprecated dependencies

- Replaced all occurrences of springdoc for springfox (Open API)
- Updated to spring boot 3.3.0
- Updated to spring cloud 2023.0.0 (removed all deprecated APIs)
- Replaced spring cloud stream with functional style.
- Introduced StreamBridge in place of ```MessageChannel``` interface.

### Changes in Code

- Replaced all existing WebSecurityConfigurer Adapters.
- Replaced all occurrences of ```javax.*``` with ```jakarta.*``` as required by the latest Springframework APIs.

### Structural changes
- Added docker using ```jib-maven ``` build
- Removed auth-server in favour of spring authorization server

### To Consider
- Checking the method to replace globalResponseMessage(POST, emptyList())
- Cleaning up the store services OpenAPI config.

### Dockerization
- Used jib-maven for now (spotify dependency repository is archived)
- Can be refactored to use either ``` buildPacks``` or ``` Graalvm ```

### Testing
- Use of spring cloud stream binder tests
- Concentrated on use of binder and bindings for unit and integration tests
- Emphasis on lambda based spring cloud stream functional implementations
78 changes: 64 additions & 14 deletions config/repo/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ spring:
# It is recommended switching to BlockingLoadBalancerClient instead.
loadbalancer.ribbon.enabled: false
# Massaging provider configurations
stream.kafka.binder:
# stream.kafka.binder:
stream.kafka.bindings:
brokers: ${app.messaging.kafka.broker}
defaultBrokerPort: 9092
rabbitmq:
Expand All @@ -41,15 +42,16 @@ spring:
#password: '{cipher}702b8ae88ce0d606c42cd89dd20c43be1100951373416f5eb6f2ab57b0288665'
# Distributed Tracking configs
zipkin.sender.type: rabbit
sleuth:
traceId128: true
sampler.probability: 1.0
# sleuth:
# traceId128: true
# sampler.probability: 1.0
# Service discovery configs
eureka:
instance:
lease-renewal-interval-in-seconds: 5
lease-expiration-duration-in-seconds: 5
prefer-ip-address: true
# prefer-ip-address: true
preferIpAddress: true
client:
healthcheck.enabled: true
service-url:
Expand All @@ -62,14 +64,62 @@ ribbon:
NF-load-balancer-ping-interval: 5

# Application health and information management
# management:
ä info.git:
# mode: full
# enabled: true
# endpoints.web.exposure.include: "*"
# endpoint:
# shutdown.enabled: true
# health.show-details: always
management:
info.git:
mode: full
enabled: true
endpoints.web.exposure.include: "*"
metrics:
distribution:
percentiles-histogram:
all: true
http:
server:
requests: true
#tags:
observations:
key-values:
application: ${spring.application.name}
# getDocoota.call: true
tracing:
# enabled: true
sampling:
probability: 1.0
info:

git:
mode: full
enabled: true
java:
enabled: true
os:
enabled: true
endpoints:
web:
exposure:
include: "*" #health, prometheus #"*"
jmx:
exposure:
include: "*"
health:
circuitbreakers:
enabled: true
# prometheus
prometheus:
metrics:
export:
step: 10s
endpoint:
shutdown.enabled: true
health.show-details: always

health:
probes:
enabled: true
show-components: always
show-details: always

logging.level:
org:
Expand All @@ -86,7 +136,7 @@ logging.level:
# docker profile
---
spring:
profiles: docker
config.activate.on-profile: docker
jmx.enabled: false

app:
Expand All @@ -104,9 +154,9 @@ app:
# Kafka profile
---
spring:
profiles: kafka
config.activate.on-profile: kafka
cloud.stream.defaultBinder: kafka
zipkin.sender.type: kafka
kafka.bootstrap-servers: kafka:9092

management.health.rabbit.enabled: false
management.health.rabbit.enabled: false
74 changes: 37 additions & 37 deletions config/repo/eureka-server.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
server:
port: 8761
port: 8761

logging.level:
com.netflix:
eureka: DEBUG
discovery: DEBUG

eureka:
environment: Development
datacenter: On Premise
instance:
lease-renewal-interval-in-seconds: 30
hostname: localhost #eurekaInstance Name
client:
# for development set it to false in order to not register itself to its peer.
register-with-eureka: false #Do you register yourself with Eureka Server?
fetch-registry: false #Do not get registration information through eureka
service-url.defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
# Make the number of renewals required to prevent an emergency tiny (probably 0)
renewal-percent-threshold: 0.49
environment: Development
datacenter: On Premise
instance:
lease-renewal-interval-in-seconds: 30
hostname: localhost #eurekaInstance Name
client:
# for development set it to false in order to not register itself to its peer.
register-with-eureka: false #Do you register yourself with Eureka Server?
fetch-registry: false #Do not get registration information through eureka
service-url.defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
# Make the number of renewals required to prevent an emergency tiny (probably 0)
renewal-percent-threshold: 0.49

response-cache-update-interval-ms: 5000
# Switch off self-preservation. Will turn lease expiration on and evict all instances which
# no longer sent a heartbeat and whose lease has expired.
# Self-preservation is desirable for Eureka clusters and where network outages
# (e.g. between data centers) could be possible.
# Note: the lease validity / expiration is configured in the Eureka _client_ instances
# (see eureka.instance.lease-expiration-duration-in-seconds).
enable-self-preservation: true
response-cache-update-interval-ms: 5000
# Switch off self-preservation. Will turn lease expiration on and evict all instances which
# no longer sent a heartbeat and whose lease has expired.
# Self-preservation is desirable for Eureka clusters and where network outages
# (e.g. between data centers) could be possible.
# Note: the lease validity / expiration is configured in the Eureka _client_ instances
# (see eureka.instance.lease-expiration-duration-in-seconds).
enable-self-preservation: true

# Make sure this is set to the same value as the lease renewal interval in
# Eureka _client_ instances (or slightly higher), This value is relevant for Eureka's
# calculation of the 'current renewal threshold'.
# Specifically, the following equation is used:
# current renewal threshold = (60s / expected-client-renewal-interval-seconds) *
# renewal-percent-threshold * current number of client instances.
# In this case:
# - for one registered client: 60 / 3 * 0.5 * 1 = 10.
# - for two registered clients: 60 / 3 * 0,5 * 2 = 20.
# As soon as two clients are connected:
expected-client-renewal-interval-seconds: 3
# Make sure this is set to the same value as the lease renewal interval in
# Eureka _client_ instances (or slightly higher), This value is relevant for Eureka's
# calculation of the 'current renewal threshold'.
# Specifically, the following equation is used:
# current renewal threshold = (60s / expected-client-renewal-interval-seconds) *
# renewal-percent-threshold * current number of client instances.
# In this case:
# - for one registered client: 60 / 3 * 0.5 * 1 = 10.
# - for two registered clients: 60 / 3 * 0,5 * 2 = 20.
# As soon as two clients are connected:
expected-client-renewal-interval-seconds: 3

# The interval in which the instance eviction task scans for instances with expired leases.
# Given in milliseconds.
eviction-interval-timer-in-ms: 2000
wait-time-in-ms-when-sync-empty: 0
# The interval in which the instance eviction task scans for instances with expired leases.
# Given in milliseconds.
eviction-interval-timer-in-ms: 2000
wait-time-in-ms-when-sync-empty: 0
18 changes: 15 additions & 3 deletions config/repo/product.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ spring:
cloud:
# Event-driven messages Stream config
stream:
defaultBinder: rabbit
# defaultBinder: rabbit
default-binder: rabbit
default.contentType: application/json
bindings:
input:
destination: products
group: productsGroup
contentType: application/json
productConsumer-in-0:
destination: products
group: productsGroup
consumer:
Expand All @@ -22,12 +27,19 @@ spring:
backOffMultiplier: 2.0
rabbit:
bindings:
input.consumer:
#
productConsumer-in-0:
# input.consumer:
consumer:
autoBindDlq: true
republishToDlq: true
kafka:
bindings:
input.consumer.enableDlq: true
productConsumer-in-0:
consumer:
autoBindDlq: true
republishToDlp: true
# input.consumer.enableDlq: true

server:
port: 9081
Expand Down
15 changes: 10 additions & 5 deletions config/repo/recommendation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@ spring:
# Event-driven messages Stream config
stream:
defaultBinder: rabbit
default.contentType: application/json
# default.contentType: application/json - deprecated
bindings:
input:
output:
contentType: application/json
# input: deprecated
recommendationConsumer-in-0:
destination: recommendations
group: recommendationsGroup
consumer:
consumer:
maxAttempts: 3
backOffInitialInterval: 500
backOffMaxInterval: 1000
backOffMultiplier: 2.0
rabbit:
bindings.input.consumer:
# bindings.input.consumer:
bindings.recommendationConsumer-in-0.consumer:
autoBindDlq: true
republishToDlq: true
kafka:
bindings.input.consumer.enableDlq: true
# bindings.input.consumer.enableDlq: true
bindings.recommendationConsumer-in-0.consumer.enableDlq: true

server:
port: 9082
Expand Down
14 changes: 9 additions & 5 deletions config/repo/review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ spring:
stream:
defaultBinder: rabbit
default.contentType: application/json
bindings.input:
destination: reviews
group: reviewsGroup
bindings: # .input:
output:
contentType: application/json
reviewConsumer-in-0: # chosen based on functional implementation
destination: reviews
group: reviewsGroup
consumer:
maxAttempts: 3
backOffInitialInterval: 500
backOffMaxInterval: 1000
backOffMultiplier: 2.0
rabbit.bindings.input.consumer:
# rabbit.bindings.input.consumer:
rabbit.bindings.reviewConsumer-in-0:
autoBindDlq: true
republishToDlq: true
kafka:
Expand Down Expand Up @@ -93,4 +97,4 @@ spring:
---
spring:
profiles: streaming_instance_1
cloud.stream.bindings.input.consumer.instanceIndex: 1
cloud.stream.bindings.input.consumer.instanceIndex: 1
19 changes: 11 additions & 8 deletions config/repo/store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ server:

spring:
cloud:
# Massaging provider configurations
# define function suppliers
function:
definition: storeProducer|recommendationsProducer|reviewsProducer
# Messaging provider configurations
## Event-driven messages Stream config
stream:
defaultBinder: rabbit
default.contentType: application/json
bindings:
output-products:
storeProducer-out-0:
destination: products
producer.required-groups: auditGroup
output-recommendations:
producer.required-groups: auditGroup # please check
recommendationsProducer-out-0:
destination: recommendations
producer.required-groups: auditGroup
output-reviews:
reviewsProducer-out-0:
destination: reviews
producer.required-groups: auditGroup

Expand Down Expand Up @@ -77,7 +80,7 @@ api:
description: Creates a composite product
notes: |
# Normal response
The composite product information posted to the API will be splitted up and stored as separate product-info, recommendation and review entities.
The composite product information posted to the API will be split up and stored as separate product-info, recommendation and review entities.

# Expected error responses
1. If a product with the same productId as specified in the posted information already exists,
Expand All @@ -87,7 +90,7 @@ api:
description: Deletes a product composite
notes: |
# Normal response
Entities for product information, recommendations and reviews related to the specificed productId will be deleted.
Entities for product information, recommendations and reviews related to the specified productId will be deleted.
The implementation of the delete method is idempotent, i.e. it can be called several times with the same response.
This means that a delete request of a non existing product will return <b>200 Ok</b>.

Expand Down Expand Up @@ -160,4 +163,4 @@ spring:
partition-count: 2
output-reviews.producer:
partition-key-expression: payload.key
partition-count: 2
partition-count: 2
Loading