AE86 3 rokov pred
rodič
commit
2e4f045d3c

+ 4 - 4
dbsyncer-biz/pom.xml

@@ -3,10 +3,10 @@
 <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">
 	<parent>
-		<artifactId>dbsyncer</artifactId>
-		<groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
-	</parent>
+        <artifactId>dbsyncer</artifactId>
+        <groupId>org.ghi</groupId>
+        <version>1.1.7-Beta</version>
+    </parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>dbsyncer-biz</artifactId>
 

+ 4 - 4
dbsyncer-cache/pom.xml

@@ -2,10 +2,10 @@
 <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">
 	<parent>
-		<artifactId>dbsyncer</artifactId>
-		<groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
-	</parent>
+        <artifactId>dbsyncer</artifactId>
+        <groupId>org.ghi</groupId>
+        <version>1.1.7-Beta</version>
+    </parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>dbsyncer-cache</artifactId>
 

+ 1 - 1
dbsyncer-cluster/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>dbsyncer</artifactId>
         <groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
+        <version>1.1.7-Beta</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dbsyncer-cluster</artifactId>

+ 1 - 1
dbsyncer-common/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>dbsyncer</artifactId>
         <groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
+        <version>1.1.7-Beta</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dbsyncer-common</artifactId>

+ 1 - 1
dbsyncer-connector/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>dbsyncer</artifactId>
         <groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
+        <version>1.1.7-Beta</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dbsyncer-connector</artifactId>

+ 1 - 1
dbsyncer-listener/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>dbsyncer</artifactId>
         <groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
+        <version>1.1.7-Beta</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dbsyncer-listener</artifactId>

+ 1 - 2
dbsyncer-listener/src/main/java/org/dbsyncer/listener/enums/ListenerEnum.java

@@ -6,7 +6,6 @@ import org.dbsyncer.listener.ListenerException;
 import org.dbsyncer.listener.kafka.KafkaExtractor;
 import org.dbsyncer.listener.mysql.MysqlExtractor;
 import org.dbsyncer.listener.oracle.OracleExtractor;
-import org.dbsyncer.listener.postgresql.PostgreSQLExtractor;
 import org.dbsyncer.listener.quartz.DatabaseQuartzExtractor;
 import org.dbsyncer.listener.quartz.ESQuartzExtractor;
 import org.dbsyncer.listener.sqlserver.SqlServerExtractor;
@@ -35,7 +34,7 @@ public enum ListenerEnum {
     /**
      * log_PostgreSQL
      */
-    LOG_POSTGRE_SQL(ListenerTypeEnum.LOG.getType() + ConnectorEnum.POSTGRE_SQL.getType(), PostgreSQLExtractor.class),
+//    LOG_POSTGRE_SQL(ListenerTypeEnum.LOG.getType() + ConnectorEnum.POSTGRE_SQL.getType(), PostgreSQLExtractor.class),
     /**
      * log_Kafka
      */

+ 1 - 1
dbsyncer-listener/src/main/test/ChangeDataCaptureTest.java

@@ -199,7 +199,7 @@ public class ChangeDataCaptureTest {
     public void start() throws SQLException {
         String username = "sa";
         String password = "123";
-        String url = "jdbc:sqlserver://127.0.0.1:1434;DatabaseName=test";
+        String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test";
         schema = "dbo";
         connection = DriverManager.getConnection(url, username, password);
         if (connection != null) {

+ 53 - 12
dbsyncer-listener/src/main/test/PGReplicationTest.java

@@ -1,9 +1,15 @@
 import org.dbsyncer.connector.util.DatabaseUtil;
+import org.junit.Test;
 import org.postgresql.PGConnection;
+import org.postgresql.replication.LogSequenceNumber;
 import org.postgresql.replication.PGReplicationStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.nio.ByteBuffer;
 import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.concurrent.TimeUnit;
 
@@ -14,24 +20,26 @@ import java.util.concurrent.TimeUnit;
  */
 public class PGReplicationTest {
 
-    public static void main(String[] args) throws SQLException, InterruptedException {
+    private final Logger logger = LoggerFactory.getLogger(getClass());
+    private Connection connection;
+
+    @Test
+    public void testPG() throws SQLException, InterruptedException {
         String url = "jdbc:postgresql://127.0.0.1:5432/postgres";
         String driverClassNam = "org.postgresql.Driver";
         String username = "postgres";
         String password = "123456";
-        String slotName = "test_slot";
-        Connection con = DatabaseUtil.getConnection(driverClassNam, url, username, password);
-        PGConnection replConnection = con.unwrap(PGConnection.class);
-        replConnection.getReplicationAPI()
-                .createReplicationSlot()
-                .logical()
-                .withSlotName(slotName)
-                .withOutputPlugin("wal2json")
-                .make();
-        PGReplicationStream stream = replConnection.getReplicationAPI()
+        connection = DatabaseUtil.getConnection(driverClassNam, url, username, password);
+
+        LogSequenceNumber currentLSN = query("SELECT pg_current_wal_lsn()", rs -> LogSequenceNumber.valueOf(rs.getString(1)));
+
+        PGConnection replConnection = connection.unwrap(PGConnection.class);
+        PGReplicationStream stream = replConnection
+                .getReplicationAPI()
                 .replicationStream()
                 .logical()
-                .withSlotName(slotName)
+                .withSlotName("test_slot")
+                .withStartPosition(currentLSN)
                 .start();
         while (true) {
             //non blocking receive message
@@ -49,4 +57,37 @@ public class PGReplicationTest {
 
     }
 
+    public <T> T query(String sql, ResultSetMapper mapper) {
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        T apply = null;
+        try {
+            ps = connection.prepareStatement(sql);
+            rs = ps.executeQuery();
+            if (rs.next()) {
+                apply = (T) mapper.apply(rs);
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage());
+        } finally {
+            close(rs);
+            close(ps);
+        }
+        return apply;
+    }
+
+    private void close(AutoCloseable closeable) {
+        if (null != closeable) {
+            try {
+                closeable.close();
+            } catch (Exception e) {
+                logger.error(e.getMessage());
+            }
+        }
+    }
+
+    public interface ResultSetMapper<T> {
+        T apply(ResultSet rs) throws SQLException;
+    }
+
 }

+ 1 - 1
dbsyncer-manager/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>dbsyncer</artifactId>
         <groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
+        <version>1.1.7-Beta</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dbsyncer-manager</artifactId>

+ 1 - 1
dbsyncer-monitor/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>dbsyncer</artifactId>
         <groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
+        <version>1.1.7-Beta</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dbsyncer-monitor</artifactId>

+ 1 - 1
dbsyncer-parser/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>dbsyncer</artifactId>
         <groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
+        <version>1.1.7-Beta</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dbsyncer-parser</artifactId>

+ 1 - 1
dbsyncer-plugin/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>dbsyncer</artifactId>
         <groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
+        <version>1.1.7-Beta</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dbsyncer-plugin</artifactId>

+ 1 - 1
dbsyncer-storage/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>dbsyncer</artifactId>
         <groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
+        <version>1.1.7-Beta</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dbsyncer-storage</artifactId>

+ 1 - 1
dbsyncer-web/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>dbsyncer</artifactId>
         <groupId>org.ghi</groupId>
-		<version>1.1.6-Beta</version>
+        <version>1.1.7-Beta</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dbsyncer-web</artifactId>

+ 1 - 1
dbsyncer-web/src/main/resources/application.properties

@@ -25,7 +25,7 @@ management.endpoints.web.exposure.include=*
 management.endpoint.health.show-details=always
 management.health.elasticsearch.enabled=false
 info.app.name=DBSyncer
-info.app.version=1.1.6-Beta
+info.app.version=1.1.7-Beta
 info.app.copyright=&copy;2021 ${info.app.name}(${info.app.version})<footer>Designed By <a href='https://gitee.com/ghi/dbsyncer' target='_blank' >AE86</a></footer>
 
 #All < Trace < Debug < Info < Warn < Error < Fatal < OFF

+ 1 - 1
pom.xml

@@ -6,7 +6,7 @@
 
     <groupId>org.ghi</groupId>
     <artifactId>dbsyncer</artifactId>
-	<version>1.1.6-Beta</version>
+    <version>1.1.7-Beta</version>
     <packaging>pom</packaging>
     <name>dbsyncer</name>
     <url>https://gitee.com/ghi/dbsyncer</url>