DBZ-7935 OlrNetworkClient does not disconnect when error occurs
OlrNetworkClient should disconnect if an unexpected error occurs while reading events from OpenLogReplicator.
This commit is contained in:
parent
8662f7ddd8
commit
673ed67a6f
@ -114,23 +114,31 @@ public void execute(ChangeEventSourceContext context, OraclePartition partition,
|
||||
|
||||
this.client = new OlrNetworkClient(connectorConfig);
|
||||
if (client.connect(startScn, startScnIndex)) {
|
||||
// Start read loop
|
||||
while (client.isConnected() && context.isRunning()) {
|
||||
final StreamingEvent event = client.readEvent();
|
||||
if (event != null) {
|
||||
onEvent(event);
|
||||
}
|
||||
try {
|
||||
// Start read loop
|
||||
while (client.isConnected() && context.isRunning()) {
|
||||
final StreamingEvent event = client.readEvent();
|
||||
if (event != null) {
|
||||
onEvent(event);
|
||||
}
|
||||
|
||||
if (context.isPaused()) {
|
||||
LOGGER.info("Streaming will now pause");
|
||||
context.streamingPaused();
|
||||
context.waitSnapshotCompletion();
|
||||
LOGGER.info("Streaming resumed");
|
||||
if (context.isPaused()) {
|
||||
LOGGER.info("Streaming will now pause");
|
||||
context.streamingPaused();
|
||||
context.waitSnapshotCompletion();
|
||||
LOGGER.info("Streaming resumed");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
client.disconnect();
|
||||
LOGGER.info("Client disconnected.");
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOGGER.error("Exception while disconnecting OpenLogReplicator client", e);
|
||||
}
|
||||
}
|
||||
|
||||
client.disconnect();
|
||||
LOGGER.info("Client disconnected.");
|
||||
}
|
||||
else {
|
||||
LOGGER.warn("Failed to connect to OpenLogReplicator server.");
|
||||
|
Loading…
Reference in New Issue
Block a user