add oracle datasource and tables for test cqrs and event driven read model now call rest from gateway and save in command db in srivce a and save on query db serivce a then send to kafka message queue and save on snapshot tabel on service b
This commit is contained in:
5
pom.xml
5
pom.xml
@ -96,6 +96,11 @@
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.jdbc</groupId>
|
||||
<artifactId>ojdbc8</artifactId>
|
||||
<version>19.8.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -21,6 +21,7 @@ public class UserEventListener {
|
||||
userSnapshot.setId(user.getUserId());
|
||||
userSnapshot.setUserName(user.getUsername());
|
||||
userSnapshot.setEmail(user.getEmail());
|
||||
userSnapshotRepository.save(userSnapshot);
|
||||
System.out.println("snapshot is updated" + user.getUserId());
|
||||
// userSnapshotRepository.save(userSnapshot);
|
||||
}
|
||||
|
@ -8,15 +8,15 @@ import static jakarta.persistence.GenerationType.SEQUENCE;
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(schema = "testapp", name = "user")
|
||||
@Table(schema = "TEST2", name = "USER_SNAPSHOT")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UserEntity {
|
||||
|
||||
@Id
|
||||
@SequenceGenerator(name = "seqTest", sequenceName = "testapp.person_seq", allocationSize = 1)
|
||||
@GeneratedValue(strategy = SEQUENCE, generator = "seqTest")
|
||||
// @SequenceGenerator(name = "seqTest", sequenceName = "testapp.person_seq", allocationSize = 1)
|
||||
// @GeneratedValue(strategy = SEQUENCE, generator = "seqTest")
|
||||
private Long id;
|
||||
@Column(name = "user_name")
|
||||
private String userName;
|
||||
|
19
src/main/resources/db/changelog/changes/oracleLiquibases/liquibase-1.1.xml
Executable file
19
src/main/resources/db/changelog/changes/oracleLiquibases/liquibase-1.1.xml
Executable file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||
|
||||
<property name="now" value="UNIX_TIMESTAMP()" dbms="mysql"/>
|
||||
<property name="now" value="sysdate" dbms="oracle"/>
|
||||
<property name="now" value="now()" dbms="postgresql"/>
|
||||
|
||||
<changeSet id="1.1-1-mmad" author="mmad">
|
||||
<insert schemaName="test2" tableName="person">
|
||||
<column name="id" value="1"/>
|
||||
<column name="first_name" value="mohammad"/>
|
||||
<column name="last_name" value="Reza"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
30
src/main/resources/db/changelog/changes/oracleLiquibases/liquibase-1.2.xml
Executable file
30
src/main/resources/db/changelog/changes/oracleLiquibases/liquibase-1.2.xml
Executable file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||
|
||||
<property name="now" value="UNIX_TIMESTAMP()" dbms="mysql"/>
|
||||
<property name="now" value="sysdate" dbms="oracle"/>
|
||||
<property name="now" value="now()" dbms="postgresql"/>
|
||||
|
||||
<changeSet id="1.2-1-mmad" author="mmad">
|
||||
<createTable schemaName="test2" tableName="PERSON" remarks="اشخاص">
|
||||
<column name="ID" type="NUMBER(19)" remarks="شناسه اشخاص">
|
||||
<constraints nullable="false" primaryKey="true" primaryKeyName="PK_PERSON_ID"/>
|
||||
</column>
|
||||
<column name="FIRST_NAME" type="VARCHAR2(255)" remarks="نام"/>
|
||||
<column name="LAST_NAME" type="VARCHAR2(255)" remarks="نام خانوادگی"/>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
<changeSet id="1.2-2-mmad" author="mmad">
|
||||
<createTable schemaName="test2" tableName="USER_SNAPSHOT" remarks="کاربر">
|
||||
<column name="ID" type="NUMBER(19)" remarks="شناسه کاربر">
|
||||
<constraints nullable="false" primaryKey="true" primaryKeyName="PK_USER_ID"/>
|
||||
</column>
|
||||
<column name="user_name" type="VARCHAR2(255)" remarks="نام کاربری"/>
|
||||
<column name="email" type="VARCHAR2(255)" remarks="ایمیل"/>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
@ -4,7 +4,7 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||
|
||||
<include file="changes/liquibase-1.2.xml" relativeToChangelogFile="true"/>
|
||||
<include file="changes/liquibase-1.1.xml" relativeToChangelogFile="true"/>
|
||||
<include file="changes/oracleLiquibases/liquibase-1.2.xml" relativeToChangelogFile="true"/>
|
||||
<include file="changes/oracleLiquibases/liquibase-1.1.xml" relativeToChangelogFile="true"/>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
Reference in New Issue
Block a user