From 6e876c15029334c615514721a0968fbad198cc1b Mon Sep 17 00:00:00 2001 From: Tadgh Date: Fri, 27 Aug 2021 16:29:06 -0400 Subject: [PATCH] WIP --- pom.xml | 6 ++++ .../uhn/fhir/jpa/starter/AppProperties.java | 19 ++++++++++ .../jpa/starter/BaseJpaRestfulServer.java | 5 +++ .../jpa/starter/FhirServerConfigCommon.java | 35 ++++++++++--------- src/main/resources/application.yaml | 4 +++ 5 files changed, 53 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index bee8ba7..1e434d6 100644 --- a/pom.xml +++ b/pom.xml @@ -83,6 +83,12 @@ hapi-fhir-base ${project.version} + + + ca.uhn.hapi.fhir + hapi-fhir-jpaserver-subscription + ${project.version} + diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java index 4c69373..98113b2 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -74,6 +74,9 @@ public class AppProperties { private Boolean use_apache_address_strategy = false; private Boolean use_apache_address_strategy_https = false; + private Integer bundle_batch_pool_size = 20; + private Integer bundle_batch_pool_max_size = 100; + public Boolean getUse_apache_address_strategy() { return use_apache_address_strategy; } @@ -471,6 +474,22 @@ public class AppProperties { this.install_transitive_ig_dependencies = install_transitive_ig_dependencies; } + public Integer getBundle_batch_pool_size() { + return this.bundle_batch_pool_size; + } + + public void setBundle_batch_pool_size(Integer bundle_batch_pool_size) { + this.bundle_batch_pool_size = bundle_batch_pool_size; + } + + public Integer getBundle_batch_pool_max_size() { + return bundle_batch_pool_max_size; + } + + public void setBundle_batch_pool_max_size(Integer bundle_batch_pool_max_size) { + this.bundle_batch_pool_max_size = bundle_batch_pool_max_size; + } + public static class Cors { private Boolean allow_Credentials = true; private List allowed_origin = ImmutableList.of("*"); diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java b/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java index dc16873..2ff07f1 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java @@ -373,6 +373,11 @@ public class BaseJpaRestfulServer extends RestfulServer { daoConfig.setResourceServerIdStrategy(DaoConfig.IdStrategyEnum.UUID); daoConfig.setResourceClientIdStrategy(appProperties.getClient_id_strategy()); } + //Parallel Batch GET execution settings + daoConfig.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size()); + daoConfig.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size()); + System.out.println("BATCH SIZE IS " + appProperties.getBundle_batch_pool_size()); + System.out.println("BATCH MAX SIZE IS " + appProperties.getBundle_batch_pool_max_size()); if (appProperties.getImplementationGuides() != null) { Map guides = appProperties.getImplementationGuides(); diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java index 8777e0a..74d46bc 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/FhirServerConfigCommon.java @@ -8,10 +8,16 @@ import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.config.PartitionSettings.CrossPartitionReferenceMode; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionDeliveryHandlerFactory; +import ca.uhn.fhir.jpa.subscription.match.deliver.email.EmailSenderImpl; import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender; -import ca.uhn.fhir.jpa.subscription.match.deliver.email.JavaMailEmailSender; +import ca.uhn.fhir.rest.server.mail.MailConfig; import com.google.common.base.Strings; +import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.dstu2.model.Subscription; +import org.simplejavamail.api.email.Email; +import org.simplejavamail.api.mailer.Mailer; +import org.simplejavamail.api.mailer.config.TransportStrategy; +import org.simplejavamail.mailer.MailerBuilder; import org.springframework.boot.env.YamlPropertySourceLoader; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -205,23 +211,20 @@ public class FhirServerConfigCommon { @Bean() public IEmailSender emailSender(AppProperties appProperties, Optional subscriptionDeliveryHandlerFactory) { if (appProperties.getSubscription() != null && appProperties.getSubscription().getEmail() != null) { - JavaMailEmailSender retVal = new JavaMailEmailSender(); + AppProperties.Subscription.Email email = appProperties.getSubscription().getEmail(); + MailConfig mailConfig = new MailConfig(); + mailConfig.setSmtpHostname(email.getHost()); + mailConfig.setSmtpUseStartTLS(email.getStartTlsRequired()); + mailConfig.setSmtpPort(email.getPort()); + mailConfig.setSmtpUsername(email.getUsername()); + mailConfig.setSmtpPassword(email.getPassword()); + EmailSenderImpl emailSender = new EmailSenderImpl(mailConfig); - AppProperties.Subscription.Email email = appProperties.getSubscription().getEmail(); - retVal.setSmtpServerHostname(email.getHost()); - retVal.setSmtpServerPort(email.getPort()); - retVal.setSmtpServerUsername(email.getUsername()); - retVal.setSmtpServerPassword(email.getPassword()); - retVal.setAuth(email.getAuth()); - retVal.setStartTlsEnable(email.getStartTlsEnable()); - retVal.setStartTlsRequired(email.getStartTlsRequired()); - retVal.setQuitWait(email.getQuitWait()); + if(subscriptionDeliveryHandlerFactory.isPresent()) { + subscriptionDeliveryHandlerFactory.get().setEmailSender(emailSender); + } - if(subscriptionDeliveryHandlerFactory.isPresent()) - subscriptionDeliveryHandlerFactory.get().setEmailSender(retVal); - - return retVal; - } + } return null; } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 7be4423..02cbd80 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -99,6 +99,10 @@ hapi: search-coord-max-pool-size: 100 search-coord-queue-capacity: 200 + # Threadpool size for BATCH'ed GETs in a bundle. +# bundle_batch_pool_size: 10 +# bundle_batch_pool_max_size: 50 + # logger: # error_format: 'ERROR - ${requestVerb} ${requestUrl}' # format: >-