generated from pagopa/template-java-spring-microservice
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from pagopa/PAGOPA-1695-sviluppo-pa-send-rt-l…
…ong-term-reliability Pagopa 1695 sviluppo pa send rt long term reliability
- Loading branch information
Showing
16 changed files
with
961 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/it/gov/pagopa/payments/config/QueueClientConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
40
src/main/java/it/gov/pagopa/payments/scheduler/Scheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
Oops, something went wrong.