Skip to content

Commit

Permalink
ThirdParty: properties normalized (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhermeCamposo authored Oct 11, 2022
1 parent 462755c commit 0c5b867
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

@SpringBootApplication
@EnableConfigurationProperties(ConfigProperties.class)
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,12 @@
*/
package io.connectedhealth_idaas.thirdparty;

//import javax.jms.ConnectionFactory;
import org.apache.camel.ExchangePattern;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Processor;
import org.apache.camel.component.kafka.KafkaComponent;
import org.apache.camel.component.kafka.KafkaConstants;
import org.apache.camel.component.kafka.KafkaEndpoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
//import org.springframework.jms.connection.JmsTransactionManager;
import org.springframework.stereotype.Component;
import org.apache.camel.component.jackson.JacksonDataFormat;
import org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat;
Expand All @@ -50,15 +40,6 @@
public class CamelConfiguration extends RouteBuilder {
private static final Logger log = LoggerFactory.getLogger(CamelConfiguration.class);

@Autowired
private ConfigProperties config;

@Bean
private KafkaEndpoint kafkaEndpoint(){
KafkaEndpoint kafkaEndpoint = new KafkaEndpoint();
return kafkaEndpoint;
}

@Bean
ServletRegistrationBean camelServlet() {
// use a @Bean to register the Camel servlet which we need to do
Expand All @@ -70,11 +51,11 @@ ServletRegistrationBean camelServlet() {
mapping.addUrlMappings("/idaas/*");
return mapping;
}
private String getKafkaTopicUri(String topic) {
return "kafka:" + topic +
"?brokers=" +
config.getKafkaBrokers();
}
// private String getKafkaTopicUri(String topic) {
// return "kafka:{{}}?brokers={{idaas.kafka.brokers}}" + topic +
// "?brokers=" +
// config.getKafkaBrokers();
// }

@Override
public void configure() throws Exception {
Expand Down Expand Up @@ -106,7 +87,8 @@ public void configure() throws Exception {
.setHeader("internalMsgID").exchangeProperty("internalMsgID")
.setHeader("bodyData").exchangeProperty("bodyData")
.setHeader("bodySize").exchangeProperty("bodySize")
.convertBodyTo(String.class).to(getKafkaTopicUri("hidn"))
.convertBodyTo(String.class)
.to("kafka:hidn?brokers={{idaas.kafka.brokers}}")
;
/*
* Direct actions used across platform
Expand All @@ -126,7 +108,8 @@ public void configure() throws Exception {
.setHeader("exchangeID").exchangeProperty("exchangeID")
.setHeader("internalMsgID").exchangeProperty("internalMsgID")
.setHeader("bodyData").exchangeProperty("bodyData")
.convertBodyTo(String.class).to(getKafkaTopicUri("{{idaas.integrationTopic}}"))
.convertBodyTo(String.class)
.to("kafka:{{idaas.integration.topic}}?brokers={{idaas.kafka.brokers}}")
;
/*
* Logging
Expand Down Expand Up @@ -190,7 +173,8 @@ public void configure() throws Exception {
// iDAAS KIC - Auditing Processing
.wireTap("direct:auditing")
// Send To Topic
.convertBodyTo(String.class).to(getKafkaTopicUri("{{idaas.iotintegrationTopic}}"))
.convertBodyTo(String.class)
.to("kafka:{{idaas.iot.integration.topic}}?brokers={{idaas.kafka.brokers}}")
;
/*
* Kafka Implementation for implementing Third Party FHIR Server direct connection
Expand All @@ -210,7 +194,8 @@ public void configure() throws Exception {
.when(simple("${file:ext} == 'csv'"))
.split(body().tokenize("\n"))
.streaming().unmarshal(new BindyCsvDataFormat(ReportingOutput.class))
.marshal(new JacksonDataFormat(ReportingOutput.class)).to(getKafkaTopicUri("MandatoryReporting"))
.marshal(new JacksonDataFormat(ReportingOutput.class))
.to("kafka:MandatoryReporting?brokers={{idaas.kafka.brokers}}")
// Auditing
.setProperty("processingtype").constant("csv-data")
.setProperty("appname").constant("iDAAS-Connect-ThirdParty")
Expand Down Expand Up @@ -261,7 +246,7 @@ public void process(Exchange exchange) throws Exception {
.split(body().tokenize("\n")).streaming()
.unmarshal(new BindyCsvDataFormat(CovidJohnHopkinsUSDailyData.class))
//.marshal(new JacksonDataFormat(CovidJohnHopkinsUSDailyData.class))
.to(getKafkaTopicUri("CovidDailyData"))
.to("kafka:CovidDailyData?brokers={{idaas.kafka.brokers}}")
.endChoice();
/*
* Sample: CSV Research Data to Topic
Expand All @@ -275,7 +260,7 @@ public void process(Exchange exchange) throws Exception {
.split(body().tokenize("\n")).streaming()
.unmarshal(new BindyCsvDataFormat(ResearchData.class))
.marshal(new JacksonDataFormat(ResearchData.class))
.to(getKafkaTopicUri("ResearchData"))
.to("kafka:ResearchData?brokers={{idaas.kafka.brokers}}")
// Auditing
.setProperty("processingtype").constant("csv-data")
.setProperty("appname").constant("iDAAS-Connect-ThirdParty")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ server.port=9983
# Management App Server Address
server.address=0.0.0.0
management.address=0.0.0.0
idaas.kafkaBrokers=localhost:9092
idaas.integrationTopic=opsmgmt_platformtransactions
idaas.appintegrationTopic=opsmgmt_platformappintgrtn
idaas.iotintegrationTopic=iot
idaas.kafka.brokers=localhost:9092
idaas.integration.topic=opsmgmt_platformtransactions
idaas.app.integration.topic=opsmgmt_platformappintgrtn
idaas.iot.integration.topic=iot
# Public Cloud
idaas.cloudTopic=idaas_cloud
idaas.processPublicCloud=false
idaas.cloudAPI=urlendpoint
idaas.cloud.topic=idaas_cloud
idaas.process.public-cloud=false
idaas.cloud.api=urlendpoint
# JDBC Database
spring.datasource.url=jdbc:postgresql://localhost/:5432/idaas_thirdparty
spring.datasource.username=postgres
Expand Down

0 comments on commit 0c5b867

Please sign in to comment.