Upgrade RocketMQ to 4.9.2.

fix when 'spring-boot-starter-actuator' doesn't exist, throw ClassNotFount.
add example.
optimize pom.
pull/2406/head
Freeman Lau 3 years ago
parent 35e0d7a1a7
commit 842ea176c0

@ -90,7 +90,7 @@
<curator.version>4.0.1</curator.version>
<!-- Apache RocketMQ -->
<rocketmq.version>4.6.1</rocketmq.version>
<rocketmq.version>4.9.2</rocketmq.version>
<!-- Maven Plugin Versions -->
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>

@ -22,6 +22,10 @@
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>

@ -61,6 +61,8 @@ public class RocketMQComprehensiveApplication {
return flux -> flux.map(user -> {
user.setId(String.valueOf(
Long.parseLong(user.getId()) * Long.parseLong(user.getId())));
user.setName("not freeman");
user.getMeta().put("hobbies", Arrays.asList("programming"));
return user;
});
}

@ -5,24 +5,32 @@ spring:
name: rocketmq-comprehensive-example
cloud:
stream:
function:
definition: producer;consumer;processor
rocketmq:
binder:
name-server: 127.0.0.1:9876
function:
definition: producer;processor;consumer
bindings:
# TODO producer must have a group, need optimization !!!
producer-out-0:
producer:
group: output_1
processor-out-0:
producer:
group: output_2
bindings:
producer-out-0:
destination: num
group: producer_group
processor-in-0:
destination: num
group: processor_group
processor-out-0:
destination: square
processor-in-0:
destination: num
group: processor_group
consumer-in-0:
destination: square
group: consumer_group
logging:
level:
org.apache.rocketmq: debug
org.springframework.context.support: debug

@ -24,24 +24,6 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
@ -56,18 +38,13 @@
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-acl</artifactId>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

@ -48,7 +48,7 @@ public class ExtendedBindingHandlerMappingsProviderConfiguration {
}
@Bean
public RocketMQConfigBeanPostProcessor rocketMQConfigBeanPostProcessor() {
public static RocketMQConfigBeanPostProcessor rocketMQConfigBeanPostProcessor() {
return new RocketMQConfigBeanPostProcessor();
}

@ -24,6 +24,7 @@ import com.alibaba.cloud.stream.binder.rocketmq.provisioning.RocketMQTopicProvis
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
@ -46,13 +47,6 @@ public class RocketMQBinderAutoConfiguration {
@Autowired
private RocketMQBinderConfigurationProperties rocketBinderConfigurationProperties;
@Bean
@ConditionalOnEnabledHealthIndicator("rocketmq")
@ConditionalOnClass(name = "org.springframework.boot.actuate.health.HealthIndicator")
public RocketMQBinderHealthIndicator rocketMQBinderHealthIndicator() {
return new RocketMQBinderHealthIndicator();
}
@Bean
public RocketMQTopicProvisioner rocketMQTopicProvisioner() {
return new RocketMQTopicProvisioner();
@ -65,4 +59,16 @@ public class RocketMQBinderAutoConfiguration {
extendedBindingProperties, provisioningProvider);
}
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(HealthIndicator.class)
@ConditionalOnEnabledHealthIndicator("rocketmq")
static class KafkaBinderHealthIndicatorConfiguration {
@Bean
public RocketMQBinderHealthIndicator rocketMQBinderHealthIndicator() {
return new RocketMQBinderHealthIndicator();
}
}
}

@ -33,7 +33,7 @@ import org.springframework.messaging.converter.CompositeMessageConverter;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.CollectionUtils;
import org.springframework.util.MimeTypeUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
/**
* @author zkzlx
@ -138,13 +138,13 @@ public final class RocketMQMessageConverterSupport {
if (Objects.nonNull(headers) && !headers.isEmpty()) {
Object tag = headers.getOrDefault(Headers.TAGS,
headers.get(toRocketHeaderKey(Headers.TAGS)));
if (StringUtils.hasLength(tag.toString())) {
if (!ObjectUtils.isEmpty(tag)) {
rocketMsg.setTags(String.valueOf(tag));
}
Object keys = headers.getOrDefault(Headers.KEYS,
headers.get(toRocketHeaderKey(Headers.KEYS)));
if (StringUtils.hasLength(keys.toString())) {
if (!ObjectUtils.isEmpty(keys)) {
rocketMsg.setKeys(keys.toString());
}
Object flagObj = headers.getOrDefault(Headers.FLAG,

@ -19,7 +19,7 @@ package com.alibaba.cloud.stream.binder.rocketmq;
import com.alibaba.cloud.stream.binder.rocketmq.autoconfigurate.RocketMQBinderAutoConfiguration;
import com.alibaba.cloud.stream.binder.rocketmq.properties.RocketMQBinderConfigurationProperties;
import com.alibaba.cloud.stream.binder.rocketmq.properties.RocketMQExtendedBindingProperties;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

Loading…
Cancel
Save