From 6805fac8a25acc3cfafca63ba76df82849b3129b Mon Sep 17 00:00:00 2001 From: panzhi Date: Sat, 10 Feb 2024 12:35:48 +0800 Subject: [PATCH] [ISSUE #625] Fix compile failed (#624) * fix compile failed * fix compile failed --- ...ketMQMessageListenerBeanPostProcessor.java | 10 ++++----- .../spring/core/RocketMQTemplate.java | 3 +-- ...etMQMessageListenerContainerRegistrar.java | 22 ++++++++++++++++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/annotation/RocketMQMessageListenerBeanPostProcessor.java b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/annotation/RocketMQMessageListenerBeanPostProcessor.java index 82269835..bf53ecbd 100644 --- a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/annotation/RocketMQMessageListenerBeanPostProcessor.java +++ b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/annotation/RocketMQMessageListenerBeanPostProcessor.java @@ -16,7 +16,7 @@ */ package org.apache.rocketmq.spring.annotation; -import org.apache.rocketmq.spring.autoconfigure.ListenerContainerConfiguration; +import org.apache.rocketmq.spring.support.RocketMQMessageListenerContainerRegistrar; import org.springframework.aop.support.AopUtils; import org.springframework.beans.BeansException; import org.springframework.beans.factory.InitializingBean; @@ -38,7 +38,7 @@ public class RocketMQMessageListenerBeanPostProcessor implements ApplicationCont private AnnotationEnhancer enhancer; - private ListenerContainerConfiguration listenerContainerConfiguration; + private RocketMQMessageListenerContainerRegistrar listenerContainerRegistrar; @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { @@ -51,8 +51,8 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw RocketMQMessageListener ann = targetClass.getAnnotation(RocketMQMessageListener.class); if (ann != null) { RocketMQMessageListener enhance = enhance(targetClass, ann); - if (listenerContainerConfiguration != null) { - listenerContainerConfiguration.registerContainer(beanName, bean, enhance); + if (listenerContainerRegistrar != null) { + listenerContainerRegistrar.registerContainer(beanName, bean, enhance); } } return bean; @@ -66,7 +66,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws @Override public void afterPropertiesSet() throws Exception { buildEnhancer(); - this.listenerContainerConfiguration = this.applicationContext.getBean(ListenerContainerConfiguration.class); + this.listenerContainerRegistrar = this.applicationContext.getBean(RocketMQMessageListenerContainerRegistrar.class); } private void buildEnhancer() { diff --git a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/core/RocketMQTemplate.java b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/core/RocketMQTemplate.java index f6af52b0..1c9910b8 100644 --- a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/core/RocketMQTemplate.java +++ b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/core/RocketMQTemplate.java @@ -450,8 +450,7 @@ public void sendAndReceive(String destination, Message message, } else { producer.request(rocketMsg, messageQueueSelector, hashKey, requestCallback, timeout); } - } catch ( - Exception e) { + } catch (Exception e) { log.error("send request message failed. destination:{}, message:{} ", destination, message); throw new MessagingException(e.getMessage(), e); } diff --git a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/RocketMQMessageListenerContainerRegistrar.java b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/RocketMQMessageListenerContainerRegistrar.java index b106c181..c15d1688 100644 --- a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/RocketMQMessageListenerContainerRegistrar.java +++ b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/RocketMQMessageListenerContainerRegistrar.java @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.rocketmq.spring.support; import org.apache.rocketmq.client.AccessChannel; @@ -36,7 +53,7 @@ public class RocketMQMessageListenerContainerRegistrar implements ApplicationCon private final RocketMQMessageConverter rocketMQMessageConverter; public RocketMQMessageListenerContainerRegistrar(RocketMQMessageConverter rocketMQMessageConverter, - ConfigurableEnvironment environment, RocketMQProperties rocketMQProperties) { + ConfigurableEnvironment environment, RocketMQProperties rocketMQProperties) { this.rocketMQMessageConverter = rocketMQMessageConverter; this.environment = environment; this.rocketMQProperties = rocketMQProperties; @@ -77,8 +94,7 @@ public void registerContainer(String beanName, Object bean, RocketMQMessageListe counter.incrementAndGet()); GenericApplicationContext genericApplicationContext = (GenericApplicationContext) applicationContext; - genericApplicationContext.registerBean(containerBeanName, DefaultRocketMQListenerContainer.class, - () -> createRocketMQListenerContainer(containerBeanName, bean, annotation)); + genericApplicationContext.registerBean(containerBeanName, DefaultRocketMQListenerContainer.class, () -> createRocketMQListenerContainer(containerBeanName, bean, annotation)); DefaultRocketMQListenerContainer container = genericApplicationContext.getBean(containerBeanName, DefaultRocketMQListenerContainer.class); if (!container.isRunning()) {