Skip to content

Commit

Permalink
[ISSUE #625] Fix compile failed (#624)
Browse files Browse the repository at this point in the history
* fix compile failed

* fix compile failed
  • Loading branch information
panzhi33 authored Feb 10, 2024
1 parent 251a53e commit 6805fac
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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;
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 6805fac

Please sign in to comment.