Skip to content

Commit

Permalink
Also publishing ET-xml to pubsub
Browse files Browse the repository at this point in the history
(future replacement for protobuf-topic)
  • Loading branch information
lassetyr committed Jan 27, 2025
1 parent 87d773e commit 98d5ae5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.stereotype.Service;
import uk.org.siri.siri21.Siri;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import static org.entur.avro.realtime.siri.converter.Converter.avro2Jaxb;
Expand All @@ -20,6 +21,9 @@ public class PubsubTopicRoute extends RouteBuilder {
@Value("${anshar.outbound.camel.route.topic.et.name}")
private String etTopic;

@Value("${anshar.outbound.camel.route.topic.et.name.xml}")
private String etTopicXml;

@Value("${anshar.outbound.camel.route.topic.vm.name}")
private String vmTopic;

Expand Down Expand Up @@ -52,6 +56,7 @@ public void configure() {
.to("xslt-saxon:xsl/split.xsl")
.split().tokenizeXML("Siri").streaming()
.wireTap("direct:publish.et.avro") // Publish as Avro
.to("direct:publish.et.xml") // Publish as XML
.to("direct:map.jaxb.to.protobuf")
.wireTap("direct:log.pubsub.et.traffic")
.to(etTopic) // Send to Pub/Sub as Protobuf
Expand Down Expand Up @@ -101,6 +106,23 @@ public void configure() {
.end()
;

if (etTopicXml != null) {
from("direct:publish.et.xml")
.to(etTopicXml)
;
} else {
AtomicBoolean etTopicXmlWarned = new AtomicBoolean(false);
from("direct:publish.et.xml")
.process(p -> {
if (!etTopicXmlWarned.get()) {
log.warn("No XML topic defined for ET. Skipping XML publish.");
etTopicXmlWarned.set(true);
}
})
;
}


from("direct:publish.et.avro")
.process(avroConvertorProcessor)
.wireTap("direct:publish.et.avro.kafka")
Expand Down
5 changes: 1 addition & 4 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,11 @@ anshar.outbound.heartbeatinterval.maximum=600000
anshar.outbound.error.initialtermination=InitialTerminationTime has already passed.
anshar.outbound.error.consumeraddress=ConsumerAddress must be set.

anshar.outbound.activemq.topic.enabled=false

anshar.outbound.camel.route.topic.et.name=anshar.estimated_timetables
anshar.outbound.camel.route.topic.et.name.xml=anshar.xml.estimated_timetables
anshar.outbound.camel.route.topic.vm.name=anshar.vehicle_monitoring
anshar.outbound.camel.route.topic.sx.name=anshar.alerts

anshar.bigdata.siri.et.export.camel.url=

rutebanken.kubernetes.enabled=false

anshar.export.snapshot.cron.expression=
Expand Down

0 comments on commit 98d5ae5

Please sign in to comment.