generated from telekom/reuse-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use custom actuator endpoint to stop kafka
- Loading branch information
Showing
6 changed files
with
66 additions
and
26 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/de/telekom/horizon/comet/actuator/HorizonPreStopActuatorEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package de.telekom.horizon.comet.actuator; | ||
|
||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint; | ||
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Endpoint(id = "horizon-prestop") | ||
public class HorizonPreStopActuatorEndpoint { | ||
|
||
private final ApplicationEventPublisher applicationEventPublisher; | ||
|
||
public HorizonPreStopActuatorEndpoint(ApplicationEventPublisher applicationEventPublisher) { | ||
this.applicationEventPublisher = applicationEventPublisher; | ||
} | ||
|
||
@WriteOperation | ||
public void handlePreStop() { | ||
var event = new HorizonPreStopEvent(this, "Got PreStop request. Terminating all connections..."); | ||
applicationEventPublisher.publishEvent(event); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/de/telekom/horizon/comet/actuator/HorizonPreStopEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.telekom.horizon.comet.actuator; | ||
|
||
import org.springframework.context.ApplicationEvent; | ||
|
||
public class HorizonPreStopEvent extends ApplicationEvent { | ||
private String message; | ||
|
||
public HorizonPreStopEvent(Object source, String message) { | ||
super(source); | ||
this.message = message; | ||
} | ||
public String getMessage() { | ||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters