Skip to content

Commit

Permalink
add error message and status FAILED if kafka connection fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Oct 1, 2024
1 parent 4c50cf4 commit 0b645e8
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public void run() {

try {
listener.onStoppedByErrorAndReconnecting(error);
updateConnectorStatusToFailed(error, topicConfig.getTopic());
} catch (final Exception e) {
// log ("Unexpected error while onStoppedByErrorAndReconnecting() notification",
// e)
Expand All @@ -165,6 +166,16 @@ public void run() {
}
}

protected void updateConnectorStatusToFailed(Exception e, String topic) {
String msg = "Topic:" + topic + " --- " + e.getClass().getName() + ": "
+ e.getMessage();
if (!(e.getCause() == null)) {
msg = msg + " --- Caused by " + e.getCause().getClass().getName() + ": " + e.getCause().getMessage();
}
connectorStatus.setMessage(msg);
connectorStatus.updateStatus(ConnectorStatus.FAILED, false);
}

void close() {
if (closed) { // no atomicity/membars required
return; // since can be called only by one single thread
Expand Down

0 comments on commit 0b645e8

Please sign in to comment.