Skip to content

Commit

Permalink
Merge pull request #102 from pagopa/PAGOPA-1695-sviluppo-pa-send-rt-l…
Browse files Browse the repository at this point in the history
…ong-term-reliability

Pagopa 1695 sviluppo pa send rt long term reliability
  • Loading branch information
FedericoRuzzier authored May 8, 2024
2 parents ba7aa42 + d653c33 commit c5ac6bd
Show file tree
Hide file tree
Showing 16 changed files with 961 additions and 134 deletions.
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-gpd-payments
description: Microservice that exposes API for payment receipts retrieving and other operations
type: application
version: 0.93.0
appVersion: 0.12.21
version: 0.95.0
appVersion: 0.12.21-2-PAGOPA-1695-sviluppo-pa-send-rt-long-term-reliability
dependencies:
- name: microservice-chart
version: 2.4.0
Expand Down
9 changes: 8 additions & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-gpd-payments
tag: "0.12.21"
tag: "0.12.21-2-PAGOPA-1695-sviluppo-pa-send-rt-long-term-reliability"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -77,13 +77,20 @@ microservice-chart:
API_CONFIG_HOST: "https://api.dev.platform.pagopa.it/apiconfig/auth/api/v1"
GPS_HOST: "https://api.dev.platform.pagopa.it/gps/spontaneous-payments-service/v1"
GPD_HOST: "https://api.dev.platform.pagopa.it/gpd/api/v1"
QUEUE_NAME: "gpd-receipt-poison-queue"
DEQUEUE_LIMIT: "5"
QUEUE_SEND_INVISIBILITY_TIME: "120"
QUEUE_RECEIVE_INVISIBILITY_TIME: "300"
CRON_JOB_SCHEDULE_RETRY_ENABLED: "true"
CRON_JOB_SCHEDULE_RETRY_TRIGGER: "0 0 0,6,12,18 * * *"
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string'
APICONFIG_SUBSCRIPTION_KEY: "gpd-d-apiconfig-subscription-key"
GPD_SUBSCRIPTION_KEY: "gpd-d-gpd-subscription-key"
GPS_SUBSCRIPTION_KEY: "gpd-d-gps-subscription-key"
AZURE_TABLES_CONNECTION_STRING: "gpd-payments-d-cosmos-connection-string"
QUEUE_CONNECTION_STRING: "gpd-payments-d-queue-connection-string"
keyvault:
name: "pagopa-d-gps-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
Expand Down
9 changes: 8 additions & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-gpd-payments
tag: "0.12.21"
tag: "0.12.21-2-PAGOPA-1695-sviluppo-pa-send-rt-long-term-reliability"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -77,13 +77,20 @@ microservice-chart:
API_CONFIG_HOST: "https://api.platform.pagopa.it/apiconfig/auth/api/v1"
GPS_HOST: "https://api.platform.pagopa.it/gps/spontaneous-payments-service/v1"
GPD_HOST: "https://api.platform.pagopa.it/gpd/api/v1"
QUEUE_NAME: "gpd-receipt-poison-queue"
DEQUEUE_LIMIT: "5"
QUEUE_SEND_INVISIBILITY_TIME: "120"
QUEUE_RECEIVE_INVISIBILITY_TIME: "300"
CRON_JOB_SCHEDULE_RETRY_ENABLED: "true"
CRON_JOB_SCHEDULE_RETRY_TRIGGER: "0 0 0,6,12,18 * * *"
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-p-connection-string'
APICONFIG_SUBSCRIPTION_KEY: "gpd-p-apiconfig-subscription-key"
GPD_SUBSCRIPTION_KEY: "gpd-p-gpd-subscription-key"
GPS_SUBSCRIPTION_KEY: "gpd-p-gps-subscription-key"
AZURE_TABLES_CONNECTION_STRING: "gpd-payments-p-cosmos-connection-string"
QUEUE_CONNECTION_STRING: "gpd-payments-p-queue-connection-string"
keyvault:
name: "pagopa-p-gps-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
Expand Down
9 changes: 8 additions & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-gpd-payments
tag: "0.12.21"
tag: "0.12.21-2-PAGOPA-1695-sviluppo-pa-send-rt-long-term-reliability"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -77,13 +77,20 @@ microservice-chart:
API_CONFIG_HOST: "https://api.uat.platform.pagopa.it/apiconfig/auth/api/v1"
GPS_HOST: "https://api.uat.platform.pagopa.it/gps/spontaneous-payments-service/v1"
GPD_HOST: "https://api.uat.platform.pagopa.it/gpd/api/v1"
QUEUE_NAME: "gpd-receipt-poison-queue"
DEQUEUE_LIMIT: "5"
QUEUE_SEND_INVISIBILITY_TIME: "120"
QUEUE_RECEIVE_INVISIBILITY_TIME: "300"
CRON_JOB_SCHEDULE_RETRY_ENABLED: "true"
CRON_JOB_SCHEDULE_RETRY_TRIGGER: "0 0 0,6,12,18 * * *"
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-u-connection-string'
APICONFIG_SUBSCRIPTION_KEY: "gpd-u-apiconfig-subscription-key"
GPD_SUBSCRIPTION_KEY: "gpd-u-gpd-subscription-key"
GPS_SUBSCRIPTION_KEY: "gpd-u-gps-subscription-key"
AZURE_TABLES_CONNECTION_STRING: "gpd-payments-u-cosmos-connection-string"
QUEUE_CONNECTION_STRING: "gpd-payments-u-queue-connection-string"
keyvault:
name: "pagopa-u-gps-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Payments",
"description": "Payments",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "0.12.21"
"version": "0.12.21-2-PAGOPA-1695-sviluppo-pa-send-rt-long-term-reliability"
},
"servers": [
{
Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>payments</artifactId>
<version>0.12.21</version>
<version>0.12.21-2-PAGOPA-1695-sviluppo-pa-send-rt-long-term-reliability</version>
<name>Payments</name>
<description>Payments</description>

Expand Down Expand Up @@ -237,6 +237,11 @@
<version>2.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-queue</artifactId>
<version>12.20.2</version>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package it.gov.pagopa.payments.config;

import com.azure.storage.queue.QueueClient;
import com.azure.storage.queue.QueueClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QueueClientConfiguration {

private static String QUEUE_NAME;

private static String CONNECTION_STRING;

@Value("${azure.queue.connection.string}")
public void setConnectionStringStatic(String connectionString) {
QueueClientConfiguration.CONNECTION_STRING = connectionString;
}

@Value("${azure.queue.queueName}")
public void setTableNameStatic(String queueName) {
QueueClientConfiguration.QUEUE_NAME = queueName;
}

@Bean
public QueueClient queueClientConfig(){
return new QueueClientBuilder()
.queueName(QUEUE_NAME)
.connectionString(CONNECTION_STRING)
.buildClient();
}
}
40 changes: 40 additions & 0 deletions src/main/java/it/gov/pagopa/payments/scheduler/Scheduler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package it.gov.pagopa.payments.scheduler;

import it.gov.pagopa.payments.service.SchedulerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Component
@Slf4j
@EnableScheduling
@ConditionalOnProperty(name = "cron.job.schedule.retry.enabled", matchIfMissing = true)
public class Scheduler {

private static final String LOG_BASE_HEADER_INFO = "[OperationType: %s] - [ClassMethod: %s] - [MethodParamsToLog: %s]";
private static final String CRON_JOB = "CRON JOB";
private Thread threadOfExecution;

@Autowired
SchedulerService schedulerService;

@Scheduled(cron = "${cron.job.schedule.expression.retry.trigger}")
@Async
public void retryPaSendRT() {
log.info(String.format(LOG_BASE_HEADER_INFO, CRON_JOB, "retry sendRT", "Running at " + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now())));
schedulerService.retryFailedPaSendRT();
this.threadOfExecution = Thread.currentThread();
}

public Thread getThreadOfExecution() {
return this.threadOfExecution;
}
}

Loading

0 comments on commit c5ac6bd

Please sign in to comment.