From 25c1ab9e77cc45b545d794b820b4585386169dcf Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 30 Oct 2024 11:38:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=95=E6=93=8E=E7=AD=89MQ=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E6=8E=A5=E5=85=A5SCS=E6=A1=86=E6=9E=B6=20#7443?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stream/config/CommonEventConfiguration.kt | 4 ++++ .../BkProducerMessageHandlerCustomizer.kt | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/customizer/BkProducerMessageHandlerCustomizer.kt diff --git a/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/config/CommonEventConfiguration.kt b/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/config/CommonEventConfiguration.kt index cf5fc9a4722..7e7f4e1e847 100644 --- a/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/config/CommonEventConfiguration.kt +++ b/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/config/CommonEventConfiguration.kt @@ -2,6 +2,7 @@ package com.tencent.devops.common.stream.config import com.tencent.devops.common.event.dispatcher.SampleEventDispatcher import com.tencent.devops.common.stream.config.interceptor.BkChannelInterceptor +import com.tencent.devops.common.stream.customizer.BkProducerMessageHandlerCustomizer import org.springframework.cloud.stream.function.StreamBridge import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -15,4 +16,7 @@ class CommonEventConfiguration { @Bean @GlobalChannelInterceptor fun bkChannelInterceptor() = BkChannelInterceptor() + + @Bean + fun bkProducerMessageHandlerCustomizer() = BkProducerMessageHandlerCustomizer() } diff --git a/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/customizer/BkProducerMessageHandlerCustomizer.kt b/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/customizer/BkProducerMessageHandlerCustomizer.kt new file mode 100644 index 00000000000..ec13861fc33 --- /dev/null +++ b/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/customizer/BkProducerMessageHandlerCustomizer.kt @@ -0,0 +1,16 @@ +package com.tencent.devops.common.stream.customizer + +import org.slf4j.LoggerFactory +import org.springframework.cloud.stream.config.ProducerMessageHandlerCustomizer +import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint + +class BkProducerMessageHandlerCustomizer : ProducerMessageHandlerCustomizer { + override fun configure(handler: AmqpOutboundEndpoint, destinationName: String) { + logger.info("handler customizer , destinationName: $destinationName , handler: ${handler.beanName}") + handler.rabbitTemplate?.isUsePublisherConnection = false // 生产者和消费者共享连接池, 提高性能 + } + + companion object { + private val logger = LoggerFactory.getLogger(BkProducerMessageHandlerCustomizer::class.java) + } +} \ No newline at end of file