Skip to content

Commit 4e069b9

Browse files
meistermeierodrotbohm
authored andcommitted
GH-301 - Add Neo4j event publication repository.
1 parent bf404a5 commit 4e069b9

File tree

30 files changed

+1739
-0
lines changed

30 files changed

+1739
-0
lines changed

spring-modulith-bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@
124124
<artifactId>spring-modulith-starter-mongodb</artifactId>
125125
<version>1.1.0-SNAPSHOT</version>
126126
</dependency>
127+
<dependency>
128+
<groupId>org.springframework.modulith</groupId>
129+
<artifactId>spring-modulith-starter-neo4j</artifactId>
130+
<version>1.1.0-SNAPSHOT</version>
131+
</dependency>
127132
<dependency>
128133
<groupId>org.springframework.modulith</groupId>
129134
<artifactId>spring-modulith-starter-test</artifactId>

spring-modulith-events/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<module>spring-modulith-events-jpa</module>
2424
<module>spring-modulith-events-kafka</module>
2525
<module>spring-modulith-events-mongodb</module>
26+
<module>spring-modulith-events-neo4j</module>
2627
</modules>
2728

2829
<profiles>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<parent>
5+
<groupId>org.springframework.modulith</groupId>
6+
<artifactId>spring-modulith-events</artifactId>
7+
<version>1.1.0-SNAPSHOT</version>
8+
<relativePath>../pom.xml</relativePath>
9+
</parent>
10+
11+
<name>Spring Modulith - Events - Neo4j-based repository</name>
12+
<artifactId>spring-modulith-events-neo4j</artifactId>
13+
14+
<properties>
15+
<module.name>org.springframework.modulith.events.neo4j</module.name>
16+
</properties>
17+
18+
<dependencies>
19+
20+
<dependency>
21+
<groupId>${project.groupId}</groupId>
22+
<artifactId>spring-modulith-events-core</artifactId>
23+
<version>${project.version}</version>
24+
</dependency>
25+
26+
<dependency>
27+
<groupId>org.springframework.data</groupId>
28+
<artifactId>spring-data-neo4j</artifactId>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter-test</artifactId>
34+
<scope>test</scope>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-data-neo4j</artifactId>
40+
<scope>test</scope>
41+
</dependency>
42+
43+
<dependency>
44+
<groupId>org.testcontainers</groupId>
45+
<artifactId>neo4j</artifactId>
46+
<version>1.19.0</version>
47+
<scope>test</scope>
48+
</dependency>
49+
50+
<dependency>
51+
<groupId>org.testcontainers</groupId>
52+
<artifactId>junit-jupiter</artifactId>
53+
<version>1.19.0</version>
54+
<scope>test</scope>
55+
</dependency>
56+
57+
</dependencies>
58+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.springframework.modulith.events.neo4j;
2+
3+
import java.time.Instant;
4+
import java.util.UUID;
5+
6+
/**
7+
*
8+
* The event publication entity definition.
9+
*
10+
* @author Gerrit Meier
11+
*/
12+
public class Neo4jEventPublication {
13+
14+
public final UUID identifier;
15+
public final Instant publicationDate;
16+
public final String listenerId;
17+
public final Object event;
18+
public final String eventHash;
19+
20+
public Instant completionDate;
21+
22+
public Neo4jEventPublication(UUID identifier, Instant publicationDate, String listenerId, Object event, String eventHash) {
23+
this.identifier = identifier;
24+
this.publicationDate = publicationDate;
25+
this.listenerId = listenerId;
26+
this.event = event;
27+
this.eventHash = eventHash;
28+
}
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.springframework.modulith.events.neo4j;
2+
3+
import org.neo4j.cypherdsl.core.renderer.Configuration;
4+
import org.springframework.boot.autoconfigure.AutoConfiguration;
5+
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
6+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
7+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.data.neo4j.core.Neo4jClient;
10+
import org.springframework.modulith.events.config.EventPublicationAutoConfiguration;
11+
import org.springframework.modulith.events.config.EventPublicationConfigurationExtension;
12+
import org.springframework.modulith.events.core.EventSerializer;
13+
14+
/**
15+
* @author Gerrit Meier
16+
*/
17+
@AutoConfiguration
18+
@AutoConfigureBefore(EventPublicationAutoConfiguration.class)
19+
public class Neo4jEventPublicationAutoConfiguration implements EventPublicationConfigurationExtension {
20+
21+
@Bean
22+
Neo4jEventPublicationRepository neo4jEventPublicationRepository(Neo4jClient neo4jClient, Configuration cypherDslConfiguration, EventSerializer eventSerializer) {
23+
return new Neo4jEventPublicationRepository(neo4jClient, cypherDslConfiguration, eventSerializer);
24+
}
25+
26+
@Bean
27+
@ConditionalOnMissingBean(Configuration.class)
28+
Configuration cypherDslConfiguration() {
29+
return Configuration.defaultConfig();
30+
}
31+
32+
@Bean
33+
@ConditionalOnProperty(name = "spring.modulith.events.neo4j.event-index.enabled", havingValue = "true")
34+
Neo4jIndexInitializer neo4jIndexInitializer(Neo4jClient neo4jClient) {
35+
return new Neo4jIndexInitializer(neo4jClient);
36+
}
37+
}

0 commit comments

Comments
 (0)