Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #512]Go back and keep versions compatible #513

Merged
merged 2 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
@RocketMQMessageListener(
topic = "normal_topic_define_in_Aliware_MQ",
consumerGroup = "group_define_in_Aliware_MQ"
//accessKey = "AK" // It will read by `rocketmq.push-consumer.access-key` key
//secretKey = "SK" // It will read by `rocketmq.push-consumer.secret-key` key
//accessKey = "AK" // It will read by `rocketmq.consumer.access-key` key
//secretKey = "SK" // It will read by `rocketmq.consumer.secret-key` key
)
public class ACLStringConsumer implements RocketMQListener<String> {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
@RocketMQMessageListener(
topic = "${demo.rocketmq.transTopic}",
consumerGroup = "group_define_in_Aliware_MQ",
accessKey = "AK", // if accessKey is empty, it will read by `rocketmq.push-consumer.access-key` key
secretKey = "SK" // if accessKey is empty, it will read by `rocketmq.push-consumer.secret-key` key
accessKey = "AK", // if accessKey is empty, it will read by `rocketmq.consumer.access-key` key
secretKey = "SK" // if accessKey is empty, it will read by `rocketmq.consumer.secret-key` key
)
public class ACLStringTransactionalConsumer implements RocketMQListener<String> {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
public @interface ExtRocketMQConsumerConfiguration {

String NAME_SERVER_PLACEHOLDER = "${rocketmq.name-server:}";
String GROUP_PLACEHOLDER = "${rocketmq.push-consumer.group:}";
String TOPIC_PLACEHOLDER = "${rocketmq.push-consumer.topic:}";
String GROUP_PLACEHOLDER = "${rocketmq.pull-consumer.group:}";
String TOPIC_PLACEHOLDER = "${rocketmq.pull-consumer.topic:}";
String ACCESS_CHANNEL_PLACEHOLDER = "${rocketmq.access-channel:}";
String ACCESS_KEY_PLACEHOLDER = "${rocketmq.push-consumer.access-key:}";
String SECRET_KEY_PLACEHOLDER = "${rocketmq.push-consumer.secret-key:}";
String TRACE_TOPIC_PLACEHOLDER = "${rocketmq.push-consumer.customized-trace-topic:}";
String ACCESS_KEY_PLACEHOLDER = "${rocketmq.pull-consumer.access-key:}";
String SECRET_KEY_PLACEHOLDER = "${rocketmq.pull-consumer.secret-key:}";
String TRACE_TOPIC_PLACEHOLDER = "${rocketmq.pull-consumer.customized-trace-topic:}";

/**
* The component name of the Producer configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
public @interface RocketMQMessageListener {

String NAME_SERVER_PLACEHOLDER = "${rocketmq.name-server:}";
String ACCESS_KEY_PLACEHOLDER = "${rocketmq.push-consumer.access-key:}";
String SECRET_KEY_PLACEHOLDER = "${rocketmq.push-consumer.secret-key:}";
String TRACE_TOPIC_PLACEHOLDER = "${rocketmq.push-consumer.customized-trace-topic:}";
String ACCESS_KEY_PLACEHOLDER = "${rocketmq.consumer.access-key:}";
String SECRET_KEY_PLACEHOLDER = "${rocketmq.consumer.secret-key:}";
String TRACE_TOPIC_PLACEHOLDER = "${rocketmq.consumer.customized-trace-topic:}";
String ACCESS_CHANNEL_PLACEHOLDER = "${rocketmq.access-channel:}";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void registerContainer(String beanName, Object bean, RocketMQMessageListe
String topic = this.environment.resolvePlaceholders(annotation.topic());

boolean listenerEnabled =
(boolean) rocketMQProperties.getPushConsumer().getListeners().getOrDefault(consumerGroup, Collections.EMPTY_MAP)
(boolean) rocketMQProperties.getConsumer().getListeners().getOrDefault(consumerGroup, Collections.EMPTY_MAP)
.getOrDefault(topic, true);

if (!listenerEnabled) {
Expand Down Expand Up @@ -143,7 +143,7 @@ private DefaultRocketMQListenerContainer createRocketMQListenerContainer(String

String namespace = environment.resolvePlaceholders(annotation.namespace());
container.setNamespace(RocketMQUtil.getNamespace(namespace,
rocketMQProperties.getPushConsumer().getNamespace()));
rocketMQProperties.getConsumer().getNamespace()));
return container;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class RocketMQProperties {
* the listener is enabled by default.
*
*/
private PushConsumer pushConsumer = new PushConsumer();
private PushConsumer consumer = new PushConsumer();

public String getNameServer() {
return nameServer;
Expand Down Expand Up @@ -88,12 +88,12 @@ public void setPullConsumer(PullConsumer pullConsumer) {
this.pullConsumer = pullConsumer;
}

public PushConsumer getPushConsumer() {
return pushConsumer;
public PushConsumer getConsumer() {
return consumer;
}

public void setPushConsumer(PushConsumer pushConsumer) {
this.pushConsumer = pushConsumer;
public void setConsumer(PushConsumer consumer) {
this.consumer = consumer;
}

public static class Producer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ public void testExtRocketMQConsumer() {
public void testConsumerListener() {
runner.withPropertyValues("rocketmq.name-server=127.0.0.1:9876",
"rocketmq.producer.group=spring_rocketmq",
"rocketmq.push-consumer.listeners.spring_rocketmq.FOO_TEST_TOPIC=false",
"rocketmq.push-consumer.listeners.spring_rocketmq.FOO_TEST_TOPIC2=true").
"rocketmq.consumer.listeners.spring_rocketmq.FOO_TEST_TOPIC=false",
"rocketmq.consumer.listeners.spring_rocketmq.FOO_TEST_TOPIC2=true").
run((context) -> {
RocketMQProperties rocketMQProperties = context.getBean(RocketMQProperties.class);
assertThat(rocketMQProperties.getPushConsumer().getListeners().get("spring_rocketmq").get("FOO_TEST_TOPIC").booleanValue()).isEqualTo(false);
assertThat(rocketMQProperties.getPushConsumer().getListeners().get("spring_rocketmq").get("FOO_TEST_TOPIC2").booleanValue()).isEqualTo(true);
assertThat(rocketMQProperties.getConsumer().getListeners().get("spring_rocketmq").get("FOO_TEST_TOPIC").booleanValue()).isEqualTo(false);
assertThat(rocketMQProperties.getConsumer().getListeners().get("spring_rocketmq").get("FOO_TEST_TOPIC2").booleanValue()).isEqualTo(true);
});

}
Expand Down