Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cnde 1998+1999+2000 #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions std-processor-service/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ out/

### VS Code ###
.vscode/
**/jaxb/**
34 changes: 32 additions & 2 deletions std-processor-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ java {
}

configurations {
jaxb
compileOnly {
extendsFrom annotationProcessor
}
Expand All @@ -24,17 +25,46 @@ repositories {
}

dependencies {
// implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.apache.kafka:kafka-streams'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
implementation 'com.microsoft.sqlserver:mssql-jdbc:12.8.1.jre11'
implementation 'com.zaxxer:HikariCP:5.1.0'

runtimeOnly 'org.glassfish.jaxb:jaxb-runtime:4.0.2'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.kafka:spring-kafka-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

jaxb 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
jaxb 'org.glassfish.jaxb:jaxb-xjc:4.0.2'
}

tasks.named('test') {
useJUnitPlatform()
}


task jaxb {
System.setProperty('javax.xml.accessExternalSchema', 'all')
def jaxbTargetDir = file("src/main/java")
doLast {
jaxbTargetDir.mkdirs()
ant.taskdef(
name: 'xjc',
classname: 'com.sun.tools.xjc.XJCTask',
classpath: configurations.jaxb.asPath
)
ant.jaxbTargetDir = jaxbTargetDir
ant.xjc(
destdir: '${jaxbTargetDir}',
package: 'gov.cdc.stdprocessorservice.model.generated.jaxb',
schema: 'src/main/resources/xsd/message.xsd'
)
}
}

compileJava.dependsOn jaxb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package gov.cdc.stdprocessorservice.config;

import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;

import java.util.HashMap;
import java.util.Map;
@EnableKafka
@Configuration
public class KafkaConsumerConfig {
@Value("${spring.kafka.group-id}")
private String groupId = "";

@Value("${spring.kafka.bootstrap-servers}")
private String bootstrapServers = "";


public KafkaConsumerConfig() {}


@Bean
public ConsumerFactory<String, String> consumerFactory() {
final Map<String, Object> config = new HashMap<>();
config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
config.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
return new DefaultKafkaConsumerFactory<>(config);
}

@Bean
public ConcurrentKafkaListenerContainerFactory<String, String> kafkaListenerContainerFactory() {
ConcurrentKafkaListenerContainerFactory<String, String> factory =
new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactory());
return factory;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package gov.cdc.stdprocessorservice.config;


import jakarta.persistence.EntityManagerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
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 org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;
import java.util.HashMap;

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "msgEntityManagerFactory",
transactionManagerRef = "msgTransactionManager",
basePackages = {
"gov.cdc.stdprocessorservice.repository.msg",
}
)
public class MsgDataSourceConfig {
@Value("${spring.datasource.driverClassName}")
private String driverClassName;

@Value("${spring.datasource.msg.url}")
private String dbUrl;

@Value("${spring.datasource.username}")
private String dbUserName;

@Value("${spring.datasource.password}")
private String dbUserPassword;

@Bean(name = "msgDataSource")
public DataSource msgDataSource() {
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();

dataSourceBuilder.driverClassName(driverClassName);
dataSourceBuilder.url(dbUrl);
dataSourceBuilder.username(dbUserName);
dataSourceBuilder.password(dbUserPassword);

return dataSourceBuilder.build();
}

@Bean(name = "msgEntityManagerFactoryBuilder")
public EntityManagerFactoryBuilder msgEntityManagerFactoryBuilder() {
return new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(), new HashMap<>(), null);
}

@Bean(name = "msgEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean msgEntityManagerFactory(
EntityManagerFactoryBuilder msgEntityManagerFactoryBuilder,
@Qualifier("msgDataSource") DataSource msgDataSource) {
return msgEntityManagerFactoryBuilder
.dataSource(msgDataSource)
.packages("gov.cdc.stdprocessorservice.repository.msg")
.persistenceUnit("msg")
.build();
}

@Primary
@Bean(name = "msgTransactionManager")
public PlatformTransactionManager msgTransactionManager(
@Qualifier("msgEntityManagerFactory") EntityManagerFactory msgEntityManagerFactory) {
return new JpaTransactionManager(msgEntityManagerFactory);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package gov.cdc.stdprocessorservice.config;


import jakarta.persistence.EntityManagerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
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 org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;
import java.util.HashMap;

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "odseEntityManagerFactory",
transactionManagerRef = "odseTransactionManager",
basePackages = {
"gov.cdc.stdprocessorservice.repository.odse",
}
)
public class OdseDataSourceConfig {
@Value("${spring.datasource.driverClassName}")
private String driverClassName;

@Value("${spring.datasource.odse.url}")
private String dbUrl;

@Value("${spring.datasource.username}")
private String dbUserName;

@Value("${spring.datasource.password}")
private String dbUserPassword;

@Bean(name = "odseDataSource")
public DataSource odseDataSource() {
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();

dataSourceBuilder.driverClassName(driverClassName);
dataSourceBuilder.url(dbUrl);
dataSourceBuilder.username(dbUserName);
dataSourceBuilder.password(dbUserPassword);

return dataSourceBuilder.build();
}

@Bean(name = "odseEntityManagerFactoryBuilder")
public EntityManagerFactoryBuilder odseEntityManagerFactoryBuilder() {
return new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(), new HashMap<>(), null);
}

@Bean(name = "odseEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean odseEntityManagerFactory(
EntityManagerFactoryBuilder odseEntityManagerFactoryBuilder,
@Qualifier("odseDataSource") DataSource odseDataSource) {
return odseEntityManagerFactoryBuilder
.dataSource(odseDataSource)
.packages("gov.cdc.stdprocessorservice.repository.odse")
.persistenceUnit("odse")
.build();
}

@Primary
@Bean(name = "odseTransactionManager")
public PlatformTransactionManager odseTransactionManager(
@Qualifier("odseEntityManagerFactory") EntityManagerFactory odseEntityManagerFactory) {
return new JpaTransactionManager(odseEntityManagerFactory);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package gov.cdc.stdprocessorservice.kafka.consumer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.annotation.KafkaListener;

public class StdEventConsumer {

private static final Logger logger = LoggerFactory.getLogger(StdEventConsumer.class); //NOSONAR


@KafkaListener(
topics = "${kafka.topic.std-topic}"
)
public void handleMessage(String message){
try {

} catch (Exception e) {
logger.error("KafkaEdxLogConsumer.handleMessage: {}", e.getMessage());
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package gov.cdc.stdprocessorservice.model;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class NbsNndIntermediaryMessage {
}
Loading