Skip to content

Commit

Permalink
NOD-690: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fparisitas committed Feb 8, 2024
1 parent 60ae171 commit e902d7a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@
@SpringBootApplication
public class EventHubClientApplication implements CommandLineRunner {

private static final Logger LOGGER = LoggerFactory.getLogger(EventHubClientApplication.class);
// private final EventHubProducerClient eventHubProducerClient;
private final EventProcessorClient eventProcessorClient;

public EventHubClientApplication(//EventHubProducerClient eventHubProducerClient,
EventProcessorClient eventProcessorClient) {
// this.eventHubProducerClient = eventHubProducerClient;
public EventHubClientApplication(EventProcessorClient eventProcessorClient) {
this.eventProcessorClient = eventProcessorClient;
}

Expand All @@ -29,14 +25,6 @@ public static void main(String[] 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")));
// LOGGER.info("Successfully sent a message to Event Hubs.");
// eventHubProducerClient.close();
LOGGER.info("Stopping and closing the processor");
eventProcessorClient.stop();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class EventHubClientConfiguration {

private static final String CONSUMER_GROUP = "$Default";
private static final String STORAGE_ACCOUNT_ENDPOINT = "";
private static final String STORAGE_ACCOUNT_CONNECTION_STRING = "";
private static final String STORAGE_CONTAINER_NAME = "prova";

@Value("${nodo-dei-pagamenti-cache-rx-connection-string}")
Expand All @@ -29,16 +29,12 @@ public class EventHubClientConfiguration {

@Bean
EventHubClientBuilder eventHubClientBuilder() {
return new EventHubClientBuilder().credential(nodoCacheRxConnectionString, nodoCacheRxName,
new DefaultAzureCredentialBuilder()
.build());
return new EventHubClientBuilder().connectionString(nodoCacheRxConnectionString);
}

@Bean
BlobContainerClientBuilder blobContainerClientBuilder() {
return new BlobContainerClientBuilder().credential(new DefaultAzureCredentialBuilder()
.build())
.endpoint(STORAGE_ACCOUNT_ENDPOINT)
return new BlobContainerClientBuilder().connectionString(STORAGE_ACCOUNT_CONNECTION_STRING)
.containerName(STORAGE_CONTAINER_NAME);
}

Expand All @@ -49,26 +45,13 @@ BlobContainerAsyncClient blobContainerAsyncClient(BlobContainerClientBuilder blo

@Bean
EventProcessorClientBuilder eventProcessorClientBuilder(BlobContainerAsyncClient blobContainerAsyncClient) {
return new EventProcessorClientBuilder().credential(nodoCacheRxConnectionString, nodoCacheRxName,
new DefaultAzureCredentialBuilder()
.build())
return new EventProcessorClientBuilder().connectionString(nodoCacheRxConnectionString)
.consumerGroup(CONSUMER_GROUP)
.checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient))
.processEvent(EventHubClientConfiguration::processEvent)
.processError(EventHubClientConfiguration::processError);
}

// @Bean
// EventHubProducerClient eventHubProducerClient(EventHubClientBuilder eventHubClientBuilder) {
// return eventHubClientBuilder.buildProducerClient();
//
// }

@Bean
EventProcessorClient eventProcessorClient(EventProcessorClientBuilder eventProcessorClientBuilder) {
return eventProcessorClientBuilder.buildEventProcessorClient();
}

public static void processEvent(EventContext eventContext) {
log.info("Processing event from partition {} with sequence number {} with body: {}",
eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber(),
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true)
})
@EnableJpaRepositories(
basePackages = "it.gov.pagopa.node.cfg_sync.repository.nexi",
basePackages = "it.gov.pagopa.node.cfgsync.repository.nexi",
entityManagerFactoryRef = "nodoNexiOEntityManager",
transactionManagerRef = "nodoNexiOTransactionManager"
)
Expand All @@ -32,7 +32,7 @@ public LocalContainerEntityManagerFactoryBean nodoNexiOEntityManager() {
LocalContainerEntityManagerFactoryBean em
= new LocalContainerEntityManagerFactoryBean();
em.setDataSource(nodoNexiODataSource());
em.setPackagesToScan("it.gov.pagopa.node.cfg_sync.repository.model.nexi");
em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model.nexi");

HibernateJpaVendorAdapter vendorAdapter
= new HibernateJpaVendorAdapter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@PropertySource(value = "classpath:/application-${spring.profiles.active}.properties", ignoreResourceNotFound = true)
})
@EnableJpaRepositories(
basePackages = "it.gov.pagopa.node.cfg_sync.repository.pagopa",
basePackages = "it.gov.pagopa.node.cfgsync.repository.pagopa",
entityManagerFactoryRef = "nodoPagoPAPEntityManager",
transactionManagerRef = "nodoPagoPAPTransactionManager"
)
Expand All @@ -34,7 +34,7 @@ public LocalContainerEntityManagerFactoryBean nodoPagoPAPEntityManager() {
LocalContainerEntityManagerFactoryBean em
= new LocalContainerEntityManagerFactoryBean();
em.setDataSource(nodoPagoPAPDataSource());
em.setPackagesToScan("it.gov.pagopa.node.cfg_sync.repository.model.pagopa");
em.setPackagesToScan("it.gov.pagopa.node.cfgsync.repository.model.pagopa");

HibernateJpaVendorAdapter vendorAdapter
= new HibernateJpaVendorAdapter();
Expand Down

0 comments on commit e902d7a

Please sign in to comment.