Move code from spring-boot-actuator to spring-boot-amqp

This commit is contained in:
Andy Wilkinson
2025-05-09 09:02:06 +01:00
committed by Phillip Webb
parent ba978d48fe
commit 302a4212b5
13 changed files with 42 additions and 25 deletions

View File

@@ -18,10 +18,10 @@ package org.springframework.boot.actuate.autoconfigure.amqp;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.actuate.amqp.RabbitHealthIndicator;
import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.actuate.health.HealthContributor;
import org.springframework.boot.amqp.actuate.health.RabbitHealthIndicator;
import org.springframework.boot.amqp.autoconfigure.RabbitAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -37,7 +37,7 @@ import org.springframework.context.annotation.Bean;
* @since 2.0.0
*/
@AutoConfiguration(after = RabbitAutoConfiguration.class)
@ConditionalOnClass(RabbitTemplate.class)
@ConditionalOnClass({ RabbitHealthIndicator.class, RabbitTemplate.class })
@ConditionalOnBean(RabbitTemplate.class)
@ConditionalOnEnabledHealthIndicator("rabbit")
public class RabbitHealthContributorAutoConfiguration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import io.micrometer.core.instrument.Tags;
import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.actuate.metrics.amqp.RabbitMetrics;
import org.springframework.boot.amqp.actuate.metrics.RabbitMetrics;
import org.springframework.context.ApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.util.StringUtils;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration;
import org.springframework.boot.amqp.autoconfigure.RabbitAutoConfiguration;
import org.springframework.boot.amqp.actuate.metrics.RabbitMetrics;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@@ -37,9 +37,9 @@ import org.springframework.context.annotation.Bean;
* @author Stephane Nicoll
* @since 2.0.0
*/
@AutoConfiguration(after = { MetricsAutoConfiguration.class, RabbitAutoConfiguration.class,
SimpleMetricsExportAutoConfiguration.class })
@ConditionalOnClass({ ConnectionFactory.class, AbstractConnectionFactory.class })
@AutoConfiguration(after = { MetricsAutoConfiguration.class, SimpleMetricsExportAutoConfiguration.class },
afterName = "org.springframework.boot.amqp.autoconfigure.RabbitAutoConfiguration")
@ConditionalOnClass({ ConnectionFactory.class, AbstractConnectionFactory.class, RabbitMetrics.class })
@ConditionalOnBean({ org.springframework.amqp.rabbit.connection.ConnectionFactory.class, MeterRegistry.class })
public class RabbitMetricsAutoConfiguration {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@ package org.springframework.boot.actuate.autoconfigure.amqp;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.amqp.RabbitHealthIndicator;
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
import org.springframework.boot.amqp.actuate.health.RabbitHealthIndicator;
import org.springframework.boot.amqp.autoconfigure.RabbitAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

View File

@@ -84,7 +84,6 @@ dependencies {
optional("org.springframework:spring-web")
optional("org.springframework:spring-webmvc")
optional("org.springframework.graphql:spring-graphql")
optional("org.springframework.amqp:spring-rabbit")
optional("org.springframework.data:spring-data-couchbase")
optional("org.springframework.data:spring-data-elasticsearch")
optional("org.springframework.data:spring-data-ldap")

View File

@@ -13,11 +13,16 @@ dependencies {
api("org.springframework:spring-messaging")
api("org.springframework.amqp:spring-rabbit")
compileOnly("com.fasterxml.jackson.core:jackson-annotations")
implementation(project(":spring-boot-project:spring-boot-tx"))
optional(project(":spring-boot-project:spring-boot-actuator"))
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
optional("io.micrometer:micrometer-core")
optional("org.springframework.amqp:spring-rabbit-stream")
testCompileOnly("com.fasterxml.jackson.core:jackson-annotations")
testImplementation(project(":spring-boot-project:spring-boot-test"))
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.actuate.amqp;
package org.springframework.boot.amqp.actuate.health;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
@@ -27,7 +27,7 @@ import org.springframework.util.Assert;
* RabbitMQ messaging system.
*
* @author Christian Dupuis
* @since 1.1.0
* @since 4.0.0
*/
public class RabbitHealthIndicator extends AbstractHealthIndicator {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,6 @@
*/
/**
* Actuator support for RabbitMQ Java Client metrics.
* Health integration for AMQP and RabbitMQ.
*/
package org.springframework.boot.actuate.metrics.amqp;
package org.springframework.boot.amqp.actuate.health;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.actuate.metrics.amqp;
package org.springframework.boot.amqp.actuate.metrics;
import java.util.Collections;
@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
*
* @author Arnaud Cogoluègnes
* @author Stephane Nicoll
* @since 2.0.0
* @since 4.0.0
*/
public class RabbitMetrics implements MeterBinder {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,6 @@
*/
/**
* Actuator support for AMQP and RabbitMQ.
* Metrics for AMQP and RabbitMQ.
*/
package org.springframework.boot.actuate.amqp;
package org.springframework.boot.amqp.actuate.metrics;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.actuate.amqp;
package org.springframework.boot.amqp.actuate.health;
import java.util.Collections;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.actuate.metrics.amqp;
package org.springframework.boot.amqp.actuate.metrics;
import com.rabbitmq.client.ConnectionFactory;
import io.micrometer.core.instrument.Tags;

View File

@@ -5,6 +5,7 @@
<disallow pkg="io.micrometer" />
<disallow pkg="org.springframework.lang" />
<allow pkg=".*" regex="true" />
<subpackage name="autoconfigure">
<disallow class="org.springframework.boot.autoconfigure.jdbc.DataSourceProperties"/>
<subpackage name="web">
@@ -48,6 +49,17 @@
</subpackage>
</subpackage>
<subpackage name="[^.]+\.actuate" regex="true">
<subpackage name="endpoint">
<file name=".*Endpoint(WebExtension)?" regex="true">
<allow pkg="org.springframework.lang"/>
</file>
</subpackage>
<subpackage name="metrics">
<allow pkg="io.micrometer" />
</subpackage>
</subpackage>
<subpackage name="actuate">
<allow pkg="io.micrometer" />
<!-- Endpoint infrastructure -->
@@ -189,4 +201,5 @@
</subpackage>
</subpackage>
</import-control>