Skip to content

Commit

Permalink
Introduce an AxonServer health indicator
Browse files Browse the repository at this point in the history
Introduce an AxonServer health indicator by implementing the
AbstractHealthIndicator. It should add the connectivity of the existing
contexts within the AxonServerConnectionManager through the Health
.Builder

#1964
  • Loading branch information
smcvb committed Feb 24, 2022
1 parent 498f660 commit 2c44bec
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2021. Axon Framework
~ Copyright (c) 2010-2022. Axon Framework
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -94,6 +94,13 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>${spring.boot.version}</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2010-2022. Axon Framework
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.axonframework.actuator;

import org.axonframework.axonserver.connector.AxonServerConnectionManager;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;

/**
* An {@link AbstractHealthIndicator} implementation exposing the health of the connections made through the {@link
* AxonServerConnectionManager}. Shares information per connected context under {@code
* "{context-name}.connection.active"}.
*
* @author Steven van Beelen
* @since 4.6.0
*/
public class AxonServerHealthIndicator extends AbstractHealthIndicator {

private static final String CONNECTION = "%s.connection.active";

private final AxonServerConnectionManager connectionManager;

/**
* Constructs this health indicator, extracting health information from the given {@code connectionManager}.
*
* @param connectionManager The Axon Server CONNECTION manager to extract health information from.
*/
public AxonServerHealthIndicator(AxonServerConnectionManager connectionManager) {
this.connectionManager = connectionManager;
}

@Override
protected void doHealthCheck(Health.Builder builder) {
connectionManager.connections()
.forEach((key, value) -> builder.withDetail(String.format(CONNECTION, key), value));
}
}

0 comments on commit 2c44bec

Please sign in to comment.