From 18ab5752c7d221187a72439c82266e8cede587ce Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Wed, 11 Oct 2023 13:50:06 -0300 Subject: [PATCH] Make rabbitmq actually optional --- docker-compose.yml | 9 --------- .../events/RabbitmqEventsAutoConfiguration.java | 16 ++++++++++------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c1673bff..b94b6a5c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,12 +8,6 @@ volumes: o: bind device: $PWD/datadir -secrets: - slapd_password: - file: ./datadir/secrets/slapd_password.txt - geoserver_privileged_user_passwd: - file: ./datadir/secrets/geoserver_privileged_user_passwd.txt - services: database: image: georchestra/database:latest @@ -28,9 +22,6 @@ services: ldap: image: georchestra/ldap:latest - secrets: - - slapd_password - - geoserver_privileged_user_passwd environment: - SLAPD_ORGANISATION=georchestra - SLAPD_DOMAIN=georchestra.org diff --git a/gateway/src/main/java/org/georchestra/gateway/events/RabbitmqEventsAutoConfiguration.java b/gateway/src/main/java/org/georchestra/gateway/events/RabbitmqEventsAutoConfiguration.java index 5d423ff5..4b705fdd 100644 --- a/gateway/src/main/java/org/georchestra/gateway/events/RabbitmqEventsAutoConfiguration.java +++ b/gateway/src/main/java/org/georchestra/gateway/events/RabbitmqEventsAutoConfiguration.java @@ -1,25 +1,29 @@ package org.georchestra.gateway.events; import org.springframework.amqp.core.AmqpTemplate; +import org.springframework.amqp.core.Queue; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.listener.MessageListenerContainer; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; +import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.amqp.core.Queue; -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.gateway.config.GatewayAutoConfiguration; -import org.springframework.context.annotation.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.DependsOn; +import org.springframework.context.annotation.ImportResource; +import org.springframework.context.annotation.Profile; @Profile("!test && !it") -@Configuration(proxyBeanMethods = false) +@AutoConfiguration @AutoConfigureAfter(GatewayAutoConfiguration.class) @ImportResource({ "classpath:rabbit-listener-context.xml", "classpath:rabbit-sender-context.xml" }) -@ConditionalOnExpression("${georchestra.gateway.security.enableRabbitmqEvents:true}") +@ConditionalOnProperty(name = "georchestra.gateway.security.enableRabbitmqEvents", havingValue = "true", matchIfMissing = false) public class RabbitmqEventsAutoConfiguration { @Bean @DependsOn({ "eventTemplate" }) - public RabbitmqEventsSender eventsSender(AmqpTemplate eventTemplate) { + RabbitmqEventsSender eventsSender(AmqpTemplate eventTemplate) { return new RabbitmqEventsSender(eventTemplate); }