|
|
|
@ -13,7 +13,7 @@ import java.sql.DriverManager;
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
public class App {
|
|
|
|
|
public class OpenGaussReplication {
|
|
|
|
|
|
|
|
|
|
public static String SOURCEURL = "jdbc:postgresql://10.10.14.209:5432/ccdjzswd_db";
|
|
|
|
|
public static String USER = "postgres";
|
|
|
|
@ -45,7 +45,6 @@ public class App {
|
|
|
|
|
|
|
|
|
|
Class.forName("org.postgresql.Driver");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PgConnection conn = (PgConnection) DriverManager.getConnection(SOURCEURL, properties);
|
|
|
|
|
System.out.println("connection success!");
|
|
|
|
|
|
|
|
|
@ -70,21 +69,18 @@ public class App {
|
|
|
|
|
.start();
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
|
|
ByteBuffer byteBuffer = stream.readPending();
|
|
|
|
|
|
|
|
|
|
if (byteBuffer == null) {
|
|
|
|
|
TimeUnit.MILLISECONDS.sleep(10L);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int offset = byteBuffer.arrayOffset();
|
|
|
|
|
byte[] source = byteBuffer.array();
|
|
|
|
|
int length = source.length - offset;
|
|
|
|
|
|
|
|
|
|
String res = new String(source, offset, length);
|
|
|
|
|
|
|
|
|
|
ProducerRecord<String, String> record = new ProducerRecord<String, String>(TOPIC, res);
|
|
|
|
|
ProducerRecord<String, String> record = new ProducerRecord<>(TOPIC, res);
|
|
|
|
|
kafkaProducer.send(record);
|
|
|
|
|
System.out.println("send ok ==> " + res);
|
|
|
|
|
|