Merge pull request #2406 from DanielLiu1123/upgrade_rocketmq_4.9.2
Upgrade rocketmq 4.9.2pull/2407/head
commit
713c32a094
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
<relativePath>../../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
||||||
|
<artifactId>rocketmq-comprehensive-example</artifactId>
|
||||||
|
<name>Spring Cloud Starter Stream Alibaba RocketMQ Comprehensive Example</name>
|
||||||
|
<description>Example demonstrating how to use rocketmq to produce, process and consume</description>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<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>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<version>${maven-deploy-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013-2022 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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
|
||||||
|
*
|
||||||
|
* https://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 com.alibaba.cloud.examples;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.integration.support.StringObjectMapBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author freeman
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
public class RocketMQComprehensiveApplication {
|
||||||
|
private static final Logger log = LoggerFactory
|
||||||
|
.getLogger(RocketMQComprehensiveApplication.class);
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(RocketMQComprehensiveApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Supplier<Flux<User>> producer() {
|
||||||
|
return () -> Flux.interval(Duration.ofSeconds(2)).map(id -> {
|
||||||
|
User user = new User();
|
||||||
|
user.setId(id.toString());
|
||||||
|
user.setName("freeman");
|
||||||
|
user.setMeta(new StringObjectMapBuilder()
|
||||||
|
.put("hobbies", Arrays.asList("movies", "songs")).put("age", 21)
|
||||||
|
.get());
|
||||||
|
return user;
|
||||||
|
}).log();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Function<Flux<User>, Flux<User>> processor() {
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Consumer<User> consumer() {
|
||||||
|
return num -> log.info(num.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013-2022 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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
|
||||||
|
*
|
||||||
|
* https://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 com.alibaba.cloud.examples;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author freeman
|
||||||
|
*/
|
||||||
|
public class User {
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private Map<String, Object> meta;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getMeta() {
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMeta(Map<String, Object> meta) {
|
||||||
|
this.meta = meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "User{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", meta=" + meta
|
||||||
|
+ '}';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
server:
|
||||||
|
port: 28082
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: rocketmq-comprehensive-example
|
||||||
|
cloud:
|
||||||
|
stream:
|
||||||
|
function:
|
||||||
|
definition: producer;consumer;processor
|
||||||
|
rocketmq:
|
||||||
|
binder:
|
||||||
|
name-server: 127.0.0.1:9876
|
||||||
|
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
|
||||||
|
processor-out-0:
|
||||||
|
destination: square
|
||||||
|
processor-in-0:
|
||||||
|
destination: num
|
||||||
|
group: processor_group
|
||||||
|
consumer-in-0:
|
||||||
|
destination: square
|
||||||
|
group: consumer_group
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
org.springframework.context.support: debug
|
Loading…
Reference in New Issue