You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -46,15 +49,28 @@ class KafkaEventSink(private val config: Config,
46
49
47
50
overridefunstart() {
48
51
val streamsConfig =StreamsSinkConfiguration.from(config)
52
+
val topics = streamsTopicService.getTopics()
53
+
val isWriteableInstance =Neo4jUtils.isWriteableInstance(db)
49
54
if (!streamsConfig.enabled) {
55
+
if (topics.isNotEmpty() && isWriteableInstance) {
56
+
log.warn("You configured the following topics: $topics, in order to make the Sink work please set the `${StreamsSinkConfigurationConstants.STREAMS_CONFIG_PREFIX}${StreamsSinkConfigurationConstants.ENABLED}` to `true`")
57
+
}
50
58
return
51
59
}
52
60
log.info("Starting the Kafka Sink")
53
61
this.eventConsumer = getEventConsumerFactory()
54
62
.createStreamsEventConsumer(config.raw, log)
55
-
.withTopics(streamsTopicService.getTopics())
63
+
.withTopics(topics)
56
64
this.eventConsumer.start()
57
65
this.job = createJob()
66
+
if (isWriteableInstance) {
67
+
if (log.isDebugEnabled) {
68
+
log.debug("Subscribed topics with Cypher queries: ${streamsTopicService.getAllCypherTemplates()}")
69
+
log.debug("Subscribed topics with CDC configuration: ${streamsTopicService.getAllCDCTopics()}")
70
+
} else {
71
+
log.info("Subscribed topics: $topics")
72
+
}
73
+
}
58
74
log.info("Kafka Sink started")
59
75
}
60
76
@@ -82,11 +98,19 @@ class KafkaEventSink(private val config: Config,
82
98
returnGlobalScope.launch(Dispatchers.IO) { // TODO improve exception management
83
99
try {
84
100
while (isActive) {
85
-
eventConsumer.read { topic, data ->
101
+
if (Neo4jUtils.isWriteableInstance(db)) {
102
+
eventConsumer.read { topic, data ->
103
+
if (log.isDebugEnabled) {
104
+
log.debug("Reading data from topic $topic")
105
+
}
106
+
queryExecution.writeForTopic(topic, data)
107
+
}
108
+
} else {
109
+
val timeMillis =TimeUnit.MILLISECONDS.toMinutes(5)
86
110
if (log.isDebugEnabled) {
87
-
log.debug("Reading data from topic $topic")
111
+
log.debug("Not in a writeable instance, new check in $timeMillis millis")
0 commit comments