Skip to content

Commit d5df384

Browse files
conker84jexp
authored andcommitted
fixes #191: The latest version of plugin fails to start polling messages (#194)
1 parent 0522a06 commit d5df384

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

common/src/main/kotlin/streams/utils/Neo4jUtils.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ object Neo4jUtils {
4141
.resolveDependency(LogService::class.java)
4242
}
4343

44-
fun isEnterpriseEdition(db: GraphDatabaseAPI): Boolean {
44+
fun isCluster(db: GraphDatabaseAPI): Boolean {
4545
try {
46-
return db.execute("""
47-
CALL dbms.components() YIELD edition
48-
RETURN edition = "enterprise" AS isEnterprise
49-
""".trimIndent()).columnAs<Boolean>("isEnterprise").next()
46+
db.execute("CALL dbms.cluster.role()").columnAs<String>("role").next()
47+
return true
5048
} catch (e: QueryExecutionException) {
5149
if (e.statusCode.equals("Neo.ClientError.Procedure.ProcedureNotFound", ignoreCase = true)) {
5250
return false

common/src/test/kotlin/streams/utils/Neo4jUtilsTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package streams.utils
22

33
import org.junit.*
4-
import org.neo4j.kernel.impl.logging.LogService
54
import org.neo4j.kernel.internal.GraphDatabaseAPI
65
import org.neo4j.test.TestGraphDatabaseFactory
76
import kotlin.test.assertFalse
@@ -33,8 +32,8 @@ class Neo4jUtilsTest {
3332
}
3433

3534
@Test
36-
fun shouldCheckIfIsEnterpriseEdition() {
37-
val isEnterprise = Neo4jUtils.isEnterpriseEdition(db)
35+
fun shouldCheckIfIsACluster() {
36+
val isEnterprise = Neo4jUtils.isCluster(db)
3837
assertFalse { isEnterprise }
3938
}
4039

consumer/src/main/kotlin/streams/StreamsEventSinkExtensionFactory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class StreamsEventSinkExtensionFactory : KernelExtensionFactory<StreamsEventSink
6060
log,
6161
db)
6262
// start the Sink
63-
if (Neo4jUtils.isEnterpriseEdition(db)) {
64-
log.info("The Sink module is running in an enterprise edition, checking for the ${Neo4jUtils.LEADER}")
63+
if (Neo4jUtils.isCluster(db)) {
64+
log.info("The Sink module is running in a cluster, checking for the ${Neo4jUtils.LEADER}")
6565
Neo4jUtils.executeInLeader(db, log) { initSinkModule() }
6666
} else {
6767
// check if is writeable instance

0 commit comments

Comments
 (0)