Skip to content

Commit

Permalink
feat(oracle): add configuration for reactive oracle connection and mo…
Browse files Browse the repository at this point in the history
…ngo db (#6)

* chore(build): integrate ecommerce commons library

* chore(build): make commons build skipped by default for local build

* feat(oracle): add configuration for reactive oracle connection

* feat(mongo): add ecommerce cosmos db configuration

* fix: restore readme

* fix: restore gradle build

* fix: restore gradle build

* fix: restore settings.gradle

* fix: add env properties to README.md
  • Loading branch information
pietro-tota authored Aug 8, 2023
1 parent 08db07c commit 3e58a87
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 77 deletions.
14 changes: 13 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
DEFAULT_LOGGING_LEVEL=info
APP_LOGGING_LEVEL=debug
WEB_LOGGING_LEVEL=debug
WEB_LOGGING_LEVEL=debug

PM_ORACLE_HOST=localhost
PM_ORACLE_PORT=1523
PM_ORACLE_DATABASE_NAME=pm
PM_ORACLE_USERNAME=test
PM_ORACLE_PASSWORD=test

MONGO_HOST="pagopa-ecommerce-mongo"
MONGO_PORT=27017
MONGO_USERNAME=admin
MONGO_PASSWORD=password
MONGO_SSL_ENABLED=false
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,21 @@ to get a good default configuration.

If you want to customize the application environment, reference this table:

| Variable name | Description | type | default |
|-------------------|---------------------------------------------------------|-------------------|---------|
| MONGO_HOST | Host where MongoDB instance used to persist wallet data | hostname (string) | |
| MONGO_PORT | Port where MongoDB is bound to in MongoDB host | number | |
| MONGO_USERNAME | MongoDB username used to connect to the database | string | |
| MONGO_PASSWORD | MongoDB password used to connect to the database | string | |
| MONGO_SSL_ENABLED | Whether SSL is enabled while connecting to MongoDB | string | |
| Variable name | Description | type | default |
|-------------------------|----------------------------------------------------|-------------------|---------|
| DEFAULT_LOGGING_LEVEL | Default root application logging level | string | INFO |
| APP_LOGGING_LEVEL | Application logging level | string | INFO |
| WEB_LOGGING_LEVEL | Web logging level | string | INFO |
| MONGO_HOST | MongoDB ecommerce hostname instance | hostname (string) | |
| MONGO_PORT | Port where MongoDB is bound to in MongoDB host | number | |
| MONGO_USERNAME | MongoDB username used to connect to the database | string | |
| MONGO_PASSWORD | MongoDB password used to connect to the database | string | |
| MONGO_SSL_ENABLED | Whether SSL is enabled while connecting to MongoDB | string | |
| PM_ORACLE_HOST | PM Oracle DB hostname instance | hostname (string) | |
| PM_ORACLE_PORT | PM Oracle DB port | int | |
| PM_ORACLE_DATABASE_NAME | PM Oracle DB database name | string | |
| PM_ORACLE_USERNAME | PM Oracle DB username | string | |
| PM_ORACLE_PASSWORD | PM Oracle DB password | string | |

### Run docker container

Expand Down
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("it.pagopa:pagopa-ecommerce-commons:$ecommerceCommonsVersion")

// oracle
implementation("com.oracle.database.jdbc:ojdbc11:23.2.0.0")
implementation("com.oracle.database.r2dbc:oracle-r2dbc:1.1.1")

// ECS logback encoder
implementation("co.elastic.logging:logback-ecs-encoder:$ecsLoggingVersion")

Expand Down
3 changes: 3 additions & 0 deletions gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ com.nimbusds:content-type:2.1=compileClasspath,implementationDependenciesMetadat
com.nimbusds:lang-tag:1.5=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.nimbusds:nimbus-jose-jwt:9.9.3=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.nimbusds:oauth2-oidc-sdk:9.7=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.oracle.database.jdbc:ojdbc11:23.2.0.0=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.oracle.database.r2dbc:oracle-r2dbc:1.1.1=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.samskivert:jmustache:1.15=productionRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
com.squareup.okhttp3:mockwebserver:4.11.0=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.squareup.okhttp3:okhttp:4.10.0=productionRuntimeClasspath,runtimeClasspath
Expand Down Expand Up @@ -130,6 +132,7 @@ io.projectreactor.netty:reactor-netty-http:1.1.5=compileClasspath,implementation
io.projectreactor.netty:reactor-netty:1.1.5=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.projectreactor:reactor-core:3.5.4=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.projectreactor:reactor-test:3.5.4=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.r2dbc:r2dbc-spi:1.0.0.RELEASE=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.springfox:springfox-core:3.0.0=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.springfox:springfox-schema:3.0.0=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.springfox:springfox-spi:3.0.0=compileClasspath,implementationDependenciesMetadata,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
Expand Down
29 changes: 29 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,22 @@
<sha256 value="e25d742f13350ae271c5c344446004ae5b14daf8e8d8000a2f4641de1f7a7d61" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.oracle.database.jdbc" name="ojdbc11" version="23.2.0.0">
<artifact name="ojdbc11-23.2.0.0.jar">
<sha256 value="0d3c38495e87ada37a3e51f3c9960e081f001e37092a28b6c6948c6089b1fc39" origin="Generated by Gradle"/>
</artifact>
<artifact name="ojdbc11-23.2.0.0.pom">
<sha256 value="c1d3bccce7b1a7c3b5640b66e3cc854c54e96f7a62d3747331ecbccedcd27cc0" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.oracle.database.r2dbc" name="oracle-r2dbc" version="1.1.1">
<artifact name="oracle-r2dbc-1.1.1.jar">
<sha256 value="5061c11788886eee1b51ad382ed04ea106a6e0e4d0752d986169f13db7cf7340" origin="Generated by Gradle"/>
</artifact>
<artifact name="oracle-r2dbc-1.1.1.pom">
<sha256 value="6cf83602220113ad8b334d8e1b39c8ba1dd282b311142b7fbcaa1bb42448dcf9" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.querydsl" name="querydsl-bom" version="5.0.0">
<artifact name="querydsl-bom-5.0.0.pom">
<sha256 value="33d88ac02fc8c1bdac129dc118ffda3b17fe96bf5cf83541ddc014a29b627b1b" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -1674,6 +1690,19 @@
<sha256 value="4b8d4520ede72a0b38f5c410fe0e2af9b45ed60fc2af035cef246acbc16aa64c" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="io.r2dbc" name="r2dbc-spi" version="1.0.0.RELEASE">
<artifact name="r2dbc-spi-1.0.0.RELEASE.jar">
<sha256 value="a5846c59fea336431a4ae72ca14edbf5299b78486fa308eafb383f4ae0ea74e5" origin="Generated by Gradle"/>
</artifact>
<artifact name="r2dbc-spi-1.0.0.RELEASE.pom">
<sha256 value="9d6a7765c1baffa7d6dfd651d8e555105f1ccd218fbb2ee6123d42f03c4848b3" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="io.r2dbc" name="r2dbc-spi-parent" version="1.0.0.RELEASE">
<artifact name="r2dbc-spi-parent-1.0.0.RELEASE.pom">
<sha256 value="f7357e8f1f560835452f4a4896c0f93f4dcac72217ee8b613d6072de2e0555b4" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="io.rest-assured" name="rest-assured-bom" version="5.2.1">
<artifact name="rest-assured-bom-5.2.1.pom">
<sha256 value="c2d6d5e8bf916065bf9f6824b426c9f61b0aa5ced5b82e518309e00171902c5d" origin="Generated by Gradle"/>
Expand Down
18 changes: 14 additions & 4 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ microservice-chart:
servicePort: 8080
serviceAccount:
create: false
annotations: {}
annotations: { }
name: ""
podAnnotations: {}
podAnnotations: { }
podSecurityContext:
seccompProfile:
type: RuntimeDefault
Expand Down Expand Up @@ -71,13 +71,23 @@ microservice-chart:
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
OTEL_LOGS_EXPORTER: none
OTEL_TRACES_SAMPLER: "always_on"
PM_ORACLE_HOST: "10.70.73.22"
PM_ORACLE_PORT: "1523"
PM_ORACLE_DATABASE_NAME: "AGIDAD"
PM_ORACLE_USERNAME: "pagopa_SV"
MONGO_HOST: pagopa-d-weu-ecommerce-cosmos-account.mongo.cosmos.azure.com
MONGO_USERNAME: pagopa-d-weu-ecommerce-cosmos-account
MONGO_PORT: "10255"
MONGO_SSL_ENABLED: "true"
envSecret:
OTEL_EXPORTER_OTLP_HEADERS: elastic-otel-token-header
PM_ORACLE_PASSWORD: pm-oracle-db-password
MONGO_PASSWORD: mongo-ecommerce-password
keyvault:
name: "pagopa-d-ecommerce-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
nodeSelector: {}
tolerations: []
nodeSelector: { }
tolerations: [ ]
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
Expand Down
28 changes: 24 additions & 4 deletions helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ microservice-chart:
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
OTEL_LOGS_EXPORTER: none
OTEL_TRACES_SAMPLER: "always_on"
PM_ORACLE_HOST: ""
PM_ORACLE_PORT: ""
PM_ORACLE_DATABASE_NAME: ""
PM_ORACLE_USERNAME: ""
MONGO_HOST: pagopa-p-weu-ecommerce-cosmos-account.mongo.cosmos.azure.com
MONGO_USERNAME: pagopa-p-weu-ecommerce-cosmos-account
MONGO_PORT: "10255"
MONGO_SSL_ENABLED: "true"
envSecret:
OTEL_EXPORTER_OTLP_HEADERS: elastic-otel-token-header
PM_ORACLE_PASSWORD: pm-oracle-db-password
MONGO_PASSWORD: mongo-ecommerce-password
image:
repository: pagopapcommonacr.azurecr.io/pagopaecommercehelpdeskservice
tag: "0.0.0"
Expand Down Expand Up @@ -60,9 +70,9 @@ microservice-chart:
servicePort: 8080
serviceAccount:
create: false
annotations: {}
annotations: { }
name: ""
podAnnotations: {}
podAnnotations: { }
podSecurityContext:
seccompProfile:
type: RuntimeDefault
Expand Down Expand Up @@ -97,13 +107,23 @@ microservice-chart:
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
OTEL_LOGS_EXPORTER: none
OTEL_TRACES_SAMPLER: "always_on"
PM_ORACLE_HOST: ""
PM_ORACLE_PORT: ""
PM_ORACLE_DATABASE_NAME: ""
PM_ORACLE_USERNAME: ""
MONGO_HOST: pagopa-p-weu-ecommerce-cosmos-account.mongo.cosmos.azure.com
MONGO_USERNAME: pagopa-p-weu-ecommerce-cosmos-account
MONGO_PORT: "10255"
MONGO_SSL_ENABLED: "true"
envSecret:
OTEL_EXPORTER_OTLP_HEADERS: elastic-otel-token-header
PM_ORACLE_PASSWORD: pm-oracle-db-password
MONGO_PASSWORD: mongo-ecommerce-password
keyvault:
name: "pagopa-p-ecommerce-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
nodeSelector: {}
tolerations: []
nodeSelector: { }
tolerations: [ ]
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
Expand Down
28 changes: 24 additions & 4 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ microservice-chart:
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
OTEL_LOGS_EXPORTER: none
OTEL_TRACES_SAMPLER: "always_on"
PM_ORACLE_HOST: "10.70.73.22"
PM_ORACLE_PORT: "1523"
PM_ORACLE_DATABASE_NAME: "AGIDAD"
PM_ORACLE_USERNAME: "pagopa_SV"
MONGO_HOST: pagopa-u-weu-ecommerce-cosmos-account.mongo.cosmos.azure.com
MONGO_USERNAME: pagopa-u-weu-ecommerce-cosmos-account
MONGO_PORT: "10255"
MONGO_SSL_ENABLED: "true"
envSecret:
OTEL_EXPORTER_OTLP_HEADERS: elastic-otel-token-header
PM_ORACLE_PASSWORD: pm-oracle-db-password
MONGO_PASSWORD: mongo-ecommerce-password
image:
repository: pagopaucommonacr.azurecr.io/pagopaecommercehelpdeskservice
tag: "0.0.0"
Expand Down Expand Up @@ -60,9 +70,9 @@ microservice-chart:
servicePort: 8080
serviceAccount:
create: false
annotations: {}
annotations: { }
name: ""
podAnnotations: {}
podAnnotations: { }
podSecurityContext:
seccompProfile:
type: RuntimeDefault
Expand Down Expand Up @@ -97,13 +107,23 @@ microservice-chart:
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
OTEL_LOGS_EXPORTER: none
OTEL_TRACES_SAMPLER: "always_on"
PM_ORACLE_HOST: "10.70.73.22"
PM_ORACLE_PORT: "1523"
PM_ORACLE_DATABASE_NAME: "AGIDAD"
PM_ORACLE_USERNAME: "pagopa_SV"
MONGO_HOST: pagopa-u-weu-ecommerce-cosmos-account.mongo.cosmos.azure.com
MONGO_USERNAME: pagopa-u-weu-ecommerce-cosmos-account
MONGO_PORT: "10255"
MONGO_SSL_ENABLED: "true"
envSecret:
OTEL_EXPORTER_OTLP_HEADERS: elastic-otel-token-header
PM_ORACLE_PASSWORD: pm-oracle-db-password
MONGO_PASSWORD: mongo-ecommerce-password
keyvault:
name: "pagopa-u-ecommerce-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
nodeSelector: {}
tolerations: []
nodeSelector: { }
tolerations: [ ]
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package it.pagopa.ecommerce.helpdesk.configurations

import io.r2dbc.spi.ConnectionFactories
import io.r2dbc.spi.ConnectionFactory
import io.r2dbc.spi.ConnectionFactoryOptions
import java.nio.CharBuffer
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class OracleConfiguration {

@Bean
fun getPMConnectionFactory(
@Value("\${pm.oracle.host}") dbHost: String,
@Value("\${pm.oracle.port}") dbPort: Int,
@Value("\${pm.oracle.databaseName}") databaseName: String,
@Value("\${pm.oracle.userName}") username: String,
@Value("\${pm.oracle.password}") password: String
): ConnectionFactory =
ConnectionFactories.get(
ConnectionFactoryOptions.builder()
.option(ConnectionFactoryOptions.DRIVER, "oracle")
.option(ConnectionFactoryOptions.HOST, dbHost)
.option(ConnectionFactoryOptions.PORT, dbPort)
.option(ConnectionFactoryOptions.DATABASE, databaseName)
.option(ConnectionFactoryOptions.USER, username)
.option(ConnectionFactoryOptions.PASSWORD, CharBuffer.wrap(password))
.build()
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.pagopa.ecommerce.helpdesk.services

import it.pagopa.ecommerce.commons.documents.v1.TransactionActivatedEvent
import it.pagopa.generated.ecommerce.helpdesk.model.*
import java.time.OffsetDateTime
import org.slf4j.LoggerFactory
Expand All @@ -18,7 +19,11 @@ class EcommerceService {
): Mono<SearchTransactionResponseDto> {
logger.info("[helpDesk ecommerce service] searchTransaction method")
return ecommerceSearchTransactionRequestDto
.doOnNext { logger.info("Search type: ${it.type}") }
.doOnNext {
logger.info("Search type: ${it.type}")
val transactionEvent = TransactionActivatedEvent()
println(transactionEvent)
}
.map {
SearchTransactionResponseDto()
.page(PageInfoDto().current(0).results(3).total(1))
Expand Down
Loading

0 comments on commit 3e58a87

Please sign in to comment.