Skip to content

Commit

Permalink
Merge pull request #212 from RongtongJin/apache-master
Browse files Browse the repository at this point in the history
[ISSUE #211] Remove the limitation that ExtRocketMQTemplate can not keep the same nameserver as RocketMQTemplate
  • Loading branch information
vongosling committed Jan 15, 2020
2 parents 64f149b + ce94b6a commit 0ae7904
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 24 deletions.
Expand Up @@ -17,13 +17,12 @@

package org.apache.rocketmq.spring.annotation;

import org.springframework.stereotype.Component;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.stereotype.Component;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
Expand All @@ -38,7 +37,7 @@
/**
* The property of "name-server".
*/
String nameServer();
String nameServer() default "${rocketmq.name-server:}";

/**
* Name of producer.
Expand Down
Expand Up @@ -136,12 +136,5 @@ private void validate(ExtRocketMQTemplateConfiguration annotation,
"please check the @ExtRocketMQTemplateConfiguration",
annotation.value()));
}

if (rocketMQProperties.getNameServer() == null ||
rocketMQProperties.getNameServer().equals(environment.resolvePlaceholders(annotation.nameServer()))) {
throw new BeanDefinitionValidationException(
"Bad annotation definition in @ExtRocketMQTemplateConfiguration, nameServer property is same with " +
"global property, please use the default RocketMQTemplate!");
}
}
}
Expand Up @@ -33,11 +33,8 @@
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.support.BeanDefinitionValidationException;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.Message;
Expand Down Expand Up @@ -89,17 +86,6 @@ public void testDefaultMQProducer() {

@Test
public void testExtRocketMQTemplate() {
runner.withPropertyValues("rocketmq.name-server=127.0.0.1:9876").
withUserConfiguration(TestExtRocketMQTemplateConfig.class, CustomObjectMappersConfig.class).
run(new ContextConsumer<AssertableApplicationContext>() {
@Override
public void accept(AssertableApplicationContext context) throws Throwable {
Throwable th = context.getStartupFailure();
System.out.printf("th==" + th + "\n");
Assert.assertTrue(th instanceof BeanDefinitionValidationException);
}
});

runner.withPropertyValues("rocketmq.name-server=127.0.1.1:9876").
withUserConfiguration(TestExtRocketMQTemplateConfig.class, CustomObjectMappersConfig.class).
run((context) -> {
Expand Down

0 comments on commit 0ae7904

Please sign in to comment.