1

Is there any reference guide for spring boot admin upgrade? I have a legacy app that I need to upgrade from 1.5 to 2.0, but the entire API has changed & there is 0 info in the official reference guide. https://codecentric.github.io/spring-boot-admin/current/

For example, the main domain class now seems to be InstanceEvent, whereas it used to be 'Application'; but they hold completely different info. Same with the class 'AbstractStatusChangeNotifier'; which now seems to use InstanceEvent & Spring webflux...

My more specific question is: How can I get application info from spring boot admin 2.0? I used to be able to do this; which now no longer exists in the api.

public class XXXMailNotifier extends AbstractStatusChangeNotifier {

@Override
protected void doNotify(ClientApplicationEvent event) {
    try {
        helper.setText(mailContentGenerator.statusChange(event), true);
    } catch (IOException | MessagingException e) {
        logger.error(e.getMessage());
    }
}

String statusChange(ClientApplicationEvent event) throws IOException {
    ImmutableMap.Builder<String, Object> content = ImmutableMap.<String, Object>builder()
            .put("name", event.getApplication().getName())
            .put("id", event.getApplication().getId())
            .put("healthUrl", event.getApplication().getHealthUrl())
            .put("managementUrl", event.getApplication().getManagementUrl())
            .put("serviceUrl", event.getApplication().getServiceUrl())
            .put("timestamp", DATE_TIME_FORMATTER.print(new LocalDateTime(event.getApplication().getInfo().getTimestamp())));
ExaSephiroth
  • 165
  • 8

1 Answers1

0

Well, if it might help anyone... I looked in the code and found that I can get the info from the instance.registration object. You can change the above in the below:

    @Override
protected Mono<Void> doNotify(InstanceEvent event, Instance instance) {
    try {
        MimeMessage message = sender.createMimeMessage();
        MimeMessageHelper helper = new MimeMessageHelper(message, true);
        helper.setSubject(format(subject, environment, pool, instance.getRegistration().getName(), event.getInstance().getValue()));
        helper.setText(mailContentGenerator.statusChange(event, instance, getLastStatus(event.getInstance())), true);

    public String statusChange(InstanceEvent event, Instance instance, String lastStatus) throws IOException {
    Registration registration = instance.getRegistration();
    ImmutableMap.Builder<String, Object> content = ImmutableMap.<String, Object>builder()
            .put("name", registration.getName())
            .put("id", instance.getId().getValue())
            .put("healthUrl", registration.getHealthUrl())
            .put("managementUrl", registration.getManagementUrl())
            .put("serviceUrl", registration.getServiceUrl())
            .put("timestamp", DATE_TIME_FORMATTER.print(new LocalDateTime(instance.getStatusTimestamp())));
ExaSephiroth
  • 165
  • 8