From 47c854e9739dab476c1bf7bc778cec5b67067a91 Mon Sep 17 00:00:00 2001 From: Pavel Bortnik Date: Fri, 28 Jun 2024 16:08:58 +0300 Subject: [PATCH 1/2] EPMRPP-92293 || Remove rabbit version from health check --- .github/workflows/release.yml | 2 +- .../health/RabbitHealthIndicator.java | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/epam/ta/reportportal/health/RabbitHealthIndicator.java diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8fe675b7ea..a85603d5ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ on: env: GH_USER_NAME: github.actor - RELEASE_VERSION: 5.11.1 + RELEASE_VERSION: 5.11.2 REPOSITORY_URL: 'https://maven.pkg.github.com/' jobs: diff --git a/src/main/java/com/epam/ta/reportportal/health/RabbitHealthIndicator.java b/src/main/java/com/epam/ta/reportportal/health/RabbitHealthIndicator.java new file mode 100644 index 0000000000..55ab3ccfd2 --- /dev/null +++ b/src/main/java/com/epam/ta/reportportal/health/RabbitHealthIndicator.java @@ -0,0 +1,26 @@ +package com.epam.ta.reportportal.health; + +import com.rabbitmq.client.Channel; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.boot.actuate.health.AbstractHealthIndicator; +import org.springframework.boot.actuate.health.Health; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; + +@Component +public class RabbitHealthIndicator extends AbstractHealthIndicator { + + private final RabbitTemplate rabbitTemplate; + + public RabbitHealthIndicator(RabbitTemplate rabbitTemplate) { + super("Rabbit health check failed"); + Assert.notNull(rabbitTemplate, "RabbitTemplate must not be null"); + this.rabbitTemplate = rabbitTemplate; + } + + @Override + protected void doHealthCheck(Health.Builder builder) { + rabbitTemplate.execute(Channel::getConnection); + builder.up(); + } +} From 407a5e9a9999aa54fb0651859fafa5f8ec9937bd Mon Sep 17 00:00:00 2001 From: Pavel Bortnik Date: Fri, 28 Jun 2024 16:26:57 +0300 Subject: [PATCH 2/2] EPMRPP-92293 || Add missed headers --- .../health/RabbitHealthIndicator.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/com/epam/ta/reportportal/health/RabbitHealthIndicator.java b/src/main/java/com/epam/ta/reportportal/health/RabbitHealthIndicator.java index 55ab3ccfd2..f875259f44 100644 --- a/src/main/java/com/epam/ta/reportportal/health/RabbitHealthIndicator.java +++ b/src/main/java/com/epam/ta/reportportal/health/RabbitHealthIndicator.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 EPAM Systems + * + * 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 com.epam.ta.reportportal.health; import com.rabbitmq.client.Channel; @@ -7,6 +22,11 @@ import org.springframework.stereotype.Component; import org.springframework.util.Assert; +/** + * Health Indicator for rabbitmq. + * + * @author Pavel Bortnik + */ @Component public class RabbitHealthIndicator extends AbstractHealthIndicator {