diff --git a/pom.xml b/pom.xml index 8c56a196d..a62612235 100644 --- a/pom.xml +++ b/pom.xml @@ -76,12 +76,6 @@ spring-cloud-gcp-starter-pubsub ${spring-cloud-gcp.version} - - - org.springframework.integration - spring-integration-core - - org.springframework.boot spring-boot-starter-actuator diff --git a/src/main/java/org/rutebanken/tiamat/changelog/EntityChangedEventPubSubPublisher.java b/src/main/java/org/rutebanken/tiamat/changelog/EntityChangedEventPubSubPublisher.java index 32b89c404..0f642a17e 100644 --- a/src/main/java/org/rutebanken/tiamat/changelog/EntityChangedEventPubSubPublisher.java +++ b/src/main/java/org/rutebanken/tiamat/changelog/EntityChangedEventPubSubPublisher.java @@ -15,7 +15,7 @@ package org.rutebanken.tiamat.changelog; -import org.rutebanken.tiamat.config.GooglePubSubConfig; +import com.google.cloud.spring.pubsub.core.PubSubTemplate; import org.rutebanken.tiamat.model.EntityInVersionStructure; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -29,7 +29,10 @@ public class EntityChangedEventPubSubPublisher extends EntityChangedEventPublisher implements EntityChangedListener { @Autowired - private GooglePubSubConfig.PubsubOutboundGateway pubsubOutboundGateway; + private PubSubTemplate pubSubTemplate; + + @Value("${changelog.topic.name:ror.tiamat.changelog}") + private String pubSubTopic; @Value("${changelog.gcp.publish.enabled:true}") private boolean pubSubPublish; @@ -37,7 +40,7 @@ public class EntityChangedEventPubSubPublisher extends EntityChangedEventPublish @Override public void onChange(EntityInVersionStructure entity) { if (pubSubPublish && isLoggedEntity(entity)) { - pubsubOutboundGateway.sendToPubsub(toEntityChangedEvent(entity, false).toString()); + pubSubTemplate.publish(pubSubTopic,toEntityChangedEvent(entity, false).toString()); } } @@ -46,7 +49,7 @@ public void onChange(EntityInVersionStructure entity) { public void onDelete(EntityInVersionStructure entity) { if (pubSubPublish && isLoggedEntity(entity)) { - pubsubOutboundGateway.sendToPubsub(toEntityChangedEvent(entity, true).toString()); + pubSubTemplate.publish(pubSubTopic,toEntityChangedEvent(entity, true).toString()); } } } diff --git a/src/main/java/org/rutebanken/tiamat/config/GooglePubSubConfig.java b/src/main/java/org/rutebanken/tiamat/config/GooglePubSubConfig.java deleted file mode 100644 index 643447623..000000000 --- a/src/main/java/org/rutebanken/tiamat/config/GooglePubSubConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.rutebanken.tiamat.config; - -import com.google.cloud.spring.pubsub.core.PubSubTemplate; -import com.google.cloud.spring.pubsub.integration.outbound.PubSubMessageHandler; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.integration.annotation.MessagingGateway; -import org.springframework.integration.annotation.ServiceActivator; -import org.springframework.messaging.MessageHandler; - -@Configuration -@Profile("google-pubsub") -public class GooglePubSubConfig { - @Value("${changelog.topic.name:ror.tiamat.changelog}") - private String pubSubTopic; - - @Bean - @ServiceActivator(inputChannel = "pubsubOutputChannel") - public MessageHandler messageSender(PubSubTemplate pubsubTemplate) { - return new PubSubMessageHandler(pubsubTemplate, pubSubTopic); - } - - @MessagingGateway(defaultRequestChannel = "pubsubOutputChannel") - public interface PubsubOutboundGateway { - void sendToPubsub(String text); - } -}