generated from pagopa/template-java-spring-microservice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee7d9fa
commit 1f187ce
Showing
29 changed files
with
408 additions
and
260 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,4 @@ hs_err_pid* | |
|
||
# Others | ||
**/.DS_Store | ||
/docker/local-dbs/postgres-data/ |
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,15 @@ | ||
version: '3.9' | ||
services: | ||
postgres: | ||
image: postgres:14 | ||
container_name: postgres_nexi | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- ./postgres-data:/var/lib/postgresql/data | ||
- ./postgres/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql | ||
environment: | ||
- POSTGRES_DB=nodo | ||
- POSTGRES_USER=cfg | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_ROOT_PASSWORD=root |
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,6 @@ | ||
CREATE TABLE "cache" ( | ||
id varchar(20) NOT NULL, | ||
"time" timestamp NOT NULL, | ||
"cache" bytea NOT NULL, | ||
"version" varchar(32) NULL | ||
); |
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,4 @@ | ||
#!/bin/bash | ||
|
||
rm -rf postgres-data | ||
docker-compose up -d --remove-orphans --force-recreate |
79 changes: 27 additions & 52 deletions
79
src/main/java/it/gov/pagopa/node/cfgsync/Application.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 |
---|---|---|
@@ -1,52 +1,27 @@ | ||
//package it.gov.pagopa.node.cfg_sync; | ||
// | ||
//import com.azure.messaging.eventhubs.EventData; | ||
//import com.azure.messaging.eventhubs.EventHubProducerClient; | ||
//import com.azure.messaging.eventhubs.EventProcessorClient; | ||
//import lombok.extern.slf4j.Slf4j; | ||
//import org.springframework.boot.CommandLineRunner; | ||
//import org.springframework.boot.SpringApplication; | ||
//import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
//import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
//import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
//import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; | ||
//import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; | ||
// | ||
//import java.util.Collections; | ||
//import java.util.concurrent.TimeUnit; | ||
// | ||
//@SpringBootApplication | ||
//@EnableAutoConfiguration(exclude = { | ||
// DataSourceAutoConfiguration.class, | ||
// DataSourceTransactionManagerAutoConfiguration.class, | ||
// HibernateJpaAutoConfiguration.class}) | ||
//@Slf4j | ||
//public class Application implements CommandLineRunner { | ||
// | ||
//// private final EventHubProducerClient eventHubProducerClient; | ||
// private final EventProcessorClient eventProcessorClient; | ||
// | ||
// public Application(//EventHubProducerClient eventHubProducerClient, | ||
// EventProcessorClient eventProcessorClient) { | ||
//// this.eventHubProducerClient = eventHubProducerClient; | ||
// this.eventProcessorClient = eventProcessorClient; | ||
// } | ||
// | ||
// public static void main(String[] args) { | ||
// SpringApplication.run(Application.class, args); | ||
// } | ||
// | ||
// @Override | ||
// public void run(String... args) throws Exception { | ||
// eventProcessorClient.start(); | ||
// // Wait for the processor client to be ready | ||
// TimeUnit.SECONDS.sleep(10); | ||
// | ||
//// eventHubProducerClient.send(Collections.singletonList(new EventData("Hello World"))); | ||
//// log.info("Successfully sent a message to Event Hubs."); | ||
//// eventHubProducerClient.close(); | ||
// log.info("Stopping and closing the processor"); | ||
// eventProcessorClient.stop(); | ||
// } | ||
// | ||
//} | ||
package it.gov.pagopa.node.cfgsync; | ||
|
||
import com.azure.messaging.eventhubs.EventProcessorClient; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
@Slf4j | ||
public class Application implements CommandLineRunner { | ||
private final EventProcessorClient eventProcessorClient; | ||
|
||
public Application(EventProcessorClient eventProcessorClient) { | ||
this.eventProcessorClient = eventProcessorClient; | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
|
||
@Override | ||
public void run(String... args) throws Exception { | ||
eventProcessorClient.start(); | ||
} | ||
|
||
} |
30 changes: 0 additions & 30 deletions
30
src/main/java/it/gov/pagopa/node/cfgsync/EventHubClientApplication.java
This file was deleted.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
src/main/java/it/gov/pagopa/node/cfgsync/client/model/StandInManagerResponse.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,15 @@ | ||
package it.gov.pagopa.node.cfgsync.client.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class StandInManagerResponse { | ||
|
||
private List<String> stations; | ||
} |
75 changes: 0 additions & 75 deletions
75
src/main/java/it/gov/pagopa/node/cfgsync/config/EventHubClientConfiguration.java
This file was deleted.
Oops, something went wrong.
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
8 changes: 0 additions & 8 deletions
8
src/main/java/it/gov/pagopa/node/cfgsync/repository/CacheNodoPNexiRepository.java
This file was deleted.
Oops, something went wrong.
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
73 changes: 73 additions & 0 deletions
73
src/main/java/it/gov/pagopa/node/cfgsync/repository/config/NodoNexiPConfiguration.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,73 @@ | ||
package it.gov.pagopa.node.cfgsync.repository.config; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.*; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
import org.springframework.jdbc.datasource.DriverManagerDataSource; | ||
import org.springframework.orm.jpa.JpaTransactionManager; | ||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | ||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
|
||
import javax.sql.DataSource; | ||
import java.util.HashMap; | ||
|
||
@Configuration | ||
@PropertySources({ | ||
@PropertySource("classpath:/application.properties"), | ||
@PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true) | ||
}) | ||
@EnableJpaRepositories( | ||
basePackages = "it.gov.pagopa.node.cfgsync.repository.nexipostgre", | ||
entityManagerFactoryRef = "nodoNexiPEntityManager", | ||
transactionManagerRef = "nodoNexiPTransactionManager" | ||
) | ||
public class NodoNexiPConfiguration { | ||
|
||
@Autowired | ||
private Environment env; | ||
|
||
@Bean | ||
public LocalContainerEntityManagerFactoryBean nodoNexiPEntityManager() { | ||
LocalContainerEntityManagerFactoryBean em | ||
= new LocalContainerEntityManagerFactoryBean(); | ||
em.setDataSource(nodoNexiPDataSource()); | ||
em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model"); | ||
|
||
HibernateJpaVendorAdapter vendorAdapter | ||
= new HibernateJpaVendorAdapter(); | ||
em.setJpaVendorAdapter(vendorAdapter); | ||
HashMap<String, Object> properties = new HashMap<>(); | ||
properties.put("hibernate.hbm2ddl.auto", | ||
env.getProperty("hibernate.hbm2ddl.auto")); | ||
properties.put("hibernate.dialect", | ||
env.getProperty("hibernate.dialect")); | ||
em.setJpaPropertyMap(properties); | ||
|
||
return em; | ||
} | ||
|
||
@Bean | ||
public DataSource nodoNexiPDataSource() { | ||
DriverManagerDataSource dataSource | ||
= new DriverManagerDataSource(); | ||
dataSource.setDriverClassName( | ||
env.getProperty("db.nodo.nexi.postgre.datasource.driverClassName")); | ||
dataSource.setUrl(env.getProperty("db.nodo.nexi.postgre.datasource.url")); | ||
dataSource.setUsername(env.getProperty("db.nodo.nexi.postgre.datasource.username")); | ||
dataSource.setPassword(env.getProperty("db.nodo.nexi.postgre.datasource.password")); | ||
|
||
return dataSource; | ||
} | ||
|
||
@Bean | ||
public PlatformTransactionManager nodoNexiPTransactionManager() { | ||
JpaTransactionManager transactionManager | ||
= new JpaTransactionManager(); | ||
transactionManager.setEntityManagerFactory( | ||
nodoNexiPEntityManager().getObject()); | ||
|
||
return transactionManager; | ||
} | ||
} |
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
Oops, something went wrong.