This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
<!-- Debezium dependencies --> | |
<dependency> | |
<groupId>io.debezium</groupId> | |
<artifactId>debezium-embedded</artifactId> | |
<version>${io.debezium.version}</version> | |
<exclusions> | |
<exclusion> | |
<groupId>org.slf4j</groupId> | |
<artifactId>slf4j-log4j12</artifactId> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EventListener | |
public void handleOutboxEvent(OutboxEvent event) { | |
UUID uuid = UUID.randomUUID(); | |
OutBoxEntity entity = new OutBoxEntity( | |
uuid, | |
event.getAggregateId(), | |
event.getEventType(), | |
event.getPayload().toString(), | |
new Date() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Transactional | |
public StudentDTO enrollStudent(EnrollStudentDTO student) throws Exception { | |
log.info("Enroll Student details for StudentId: {}", student.getName()); | |
StudentEntity studentEntity = StudentMapper.INSTANCE.studentDTOToEntity(student); | |
studentRepository.save(studentEntity); | |
//Publish the event | |
event.fire(EventUtils.createEnrollEvent(studentEntity)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.5" | |
services: | |
# Install postgres and setup the student database. | |
postgres: | |
container_name: postgres | |
image: debezium/postgres | |
ports: | |
- 5432:5432 | |
environment: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X POST 'http://localhost:9200/family_tree/_search' \ | |
-H 'content-type: application/json' \ | |
-d '{ | |
"query":{ | |
"has_child":{ | |
"type":"child", | |
"query":{ | |
"has_child":{ | |
"type":"grandchild", | |
"query":{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Insert GrandChildren for the Fords | |
curl -X PUT \ | |
'http://localhost:9200/family_tree/_bulk?routing=Darren' -H 'content-type: application/json' \ | |
-d ' | |
{"index": {"_type": "_doc", "_id": "14"}} | |
{"firstName":"Douglas", "lastName":"Ford", "gender":"Male", "isAlive":true, "relation_type":{ "name":"grandchild", "parent":"5" } } | |
' | |
# Insert GrandChildren for the Turners | |
curl -X PUT \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X PUT 'http://localhost:9200/family_tree/_doc/14?routing=Darren' \ | |
-H 'content-type: application/json' \ | |
-d '{ | |
"firstName":"Douglas", | |
"lastName":"Ford", | |
"gender":"Male", | |
"isAlive":true, | |
"relation_type":{ | |
"name":"grandchild", | |
"parent":"5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X PUT 'http://localhost:9200/family_tree' \ | |
-H 'content-type: application/json' \ | |
-d '{ | |
"settings":{ | |
... | |
}, | |
"mappings":{ | |
"properties":{ | |
... | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X GET 'http://localhost:9200/family_tree/_search?pretty=true' \ | |
-H 'content-type: application/json' \ | |
-d '{ | |
"query":{ | |
"has_child":{ | |
"type":"wife", | |
"query":{ | |
"match_all": {} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X PUT 'http://localhost:9200/family_tree/_doc/13?routing=Darren' \ | |
-H 'content-type: application/json' \ | |
-d '{ | |
"firstName":"Melissa", | |
"lastName":"Ford", | |
"gender":"Female", | |
"isAlive":false, | |
"relation_type":{ | |
"name":"wife", | |
"parent":"1" |