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