From ec6b12e8648adaa839f0c3b6e5101485fd40c858 Mon Sep 17 00:00:00 2001 From: Yoann Isaac Date: Sun, 2 Mar 2025 23:13:31 +0100 Subject: [PATCH] Externalizes more subscription parameters (#783) * Externalizes more subscription parameters Allows : - to parametrize the polling interval of subscription - to enable the setting to queue the subscription jobs immediately. Following the change in hapifhir/hapi-fhir/pull/6395 * Fix formatting --- .../uhn/fhir/jpa/starter/AppProperties.java | 38 ++++++++++++++++--- .../common/FhirServerConfigCommon.java | 28 +++++++++++--- src/main/resources/application.yaml | 2 + 3 files changed, 57 insertions(+), 11 deletions(-) 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 cd0bf74..cfbf8b6 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -683,31 +683,41 @@ public class AppProperties { this.resource_dbhistory_enabled = resource_dbhistory_enabled; } - public Boolean getPre_expand_value_sets() { return this.pre_expand_value_sets; } + public Boolean getPre_expand_value_sets() { + return this.pre_expand_value_sets; + } public void setPre_expand_value_sets(Boolean pre_expand_value_sets) { this.pre_expand_value_sets = pre_expand_value_sets; } - public Boolean getEnable_task_pre_expand_value_sets() { return this.enable_task_pre_expand_value_sets; } + public Boolean getEnable_task_pre_expand_value_sets() { + return this.enable_task_pre_expand_value_sets; + } public void setEnable_task_pre_expand_value_setss(Boolean enable_task_pre_expand_value_sets) { this.enable_task_pre_expand_value_sets = enable_task_pre_expand_value_sets; } - public Integer getPre_expand_value_sets_default_count() {return pre_expand_value_sets_default_count; } + public Integer getPre_expand_value_sets_default_count() { + return pre_expand_value_sets_default_count; + } public void setPre_expand_value_sets_default_count(Integer pre_expand_value_sets_default_count) { this.pre_expand_value_sets_default_count = pre_expand_value_sets_default_count; } - public Integer getPre_expand_value_sets_max_count() { return pre_expand_value_sets_max_count; } + public Integer getPre_expand_value_sets_max_count() { + return pre_expand_value_sets_max_count; + } public void setPre_expand_value_sets_max_count(Integer pre_expand_value_sets_max_count) { this.pre_expand_value_sets_max_count = pre_expand_value_sets_max_count; } - public Integer getMaximum_expansion_size() { return maximum_expansion_size; } + public Integer getMaximum_expansion_size() { + return maximum_expansion_size; + } public void setMaximum_expansion_size(Integer maximum_expansion_size) { this.maximum_expansion_size = maximum_expansion_size; @@ -914,6 +924,8 @@ public class AppProperties { private Boolean resthook_enabled = false; private Boolean websocket_enabled = false; private Email email = null; + private Integer polling_interval_ms = null; + private Boolean immediately_queued = false; public Boolean getResthook_enabled() { return resthook_enabled; @@ -939,6 +951,22 @@ public class AppProperties { this.email = email; } + public Integer getPolling_interval_ms() { + return polling_interval_ms; + } + + public void setPolling_interval_ms(Integer polling_interval_ms) { + this.polling_interval_ms = polling_interval_ms; + } + + public Boolean getImmediately_queued() { + return immediately_queued; + } + + public void setImmediately_queued(Boolean immediately_queued) { + this.immediately_queued = immediately_queued; + } + public static class Email { private String from; private String host; diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java index a5046bd..3abbed5 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java @@ -90,12 +90,16 @@ public class FhirServerConfigCommon { } ourLog.info("Server configured to " + (appProperties.getPre_expand_value_sets() ? "enable" : "disable") - + " value set pre-expansion"); - ourLog.info("Server configured to " + (appProperties.getEnable_task_pre_expand_value_sets() ? "enable" : "disable") - + " value set pre-expansion task"); - ourLog.info("Server configured for pre-expand value set default count of " + (appProperties.getPre_expand_value_sets_default_count().toString())); - ourLog.info("Server configured for pre-expand value set max count of " + (appProperties.getPre_expand_value_sets_default_count().toString())); - ourLog.info("Server configured for maximum expansion size of " + (appProperties.getPre_expand_value_sets_default_count().toString())); + + " value set pre-expansion"); + ourLog.info( + "Server configured to " + (appProperties.getEnable_task_pre_expand_value_sets() ? "enable" : "disable") + + " value set pre-expansion task"); + ourLog.info("Server configured for pre-expand value set default count of " + + (appProperties.getPre_expand_value_sets_default_count().toString())); + ourLog.info("Server configured for pre-expand value set max count of " + + (appProperties.getPre_expand_value_sets_default_count().toString())); + ourLog.info("Server configured for maximum expansion size of " + + (appProperties.getPre_expand_value_sets_default_count().toString())); } @Bean @@ -122,6 +126,18 @@ public class FhirServerConfigCommon { subscriptionSettings.addSupportedSubscriptionType( org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET); } + if (appProperties.getSubscription().getPolling_interval_ms() != null) { + ourLog.info( + "Setting subscription polling interval to {} ms", + appProperties.getSubscription().getPolling_interval_ms()); + subscriptionSettings.setSubscriptionIntervalInMs( + appProperties.getSubscription().getPolling_interval_ms()); + } + if (appProperties.getSubscription().getImmediately_queued()) { + ourLog.info("Subscription update will be queued immediately"); + subscriptionSettings.setSubscriptionChangeQueuedImmediately( + appProperties.getSubscription().getImmediately_queued()); + } } if (appProperties.getMdm_enabled()) { // MDM requires the subscription of type message diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 3ea2e3c..a0756d6 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -309,6 +309,8 @@ hapi: # subscription: # resthook_enabled: true # websocket_enabled: false +# polling_interval_ms: 5000 +# immediately_queued: false # email: # from: some@test.com # host: google.com