feat: 升级SpringBoot和SpringCloud版本
This commit is contained in:
-24
@@ -1,24 +0,0 @@
|
||||
package com.rocketmq.demo.config;
|
||||
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.annotation.Input;
|
||||
import com.rocketmq.demo.config.RocketMqConfig.MySink;
|
||||
import org.springframework.cloud.stream.messaging.Sink;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
|
||||
/**
|
||||
* @author zlt
|
||||
*/
|
||||
@EnableBinding({MySink.class})
|
||||
public class RocketMqConfig {
|
||||
public interface MySink {
|
||||
@Input(Sink.INPUT)
|
||||
SubscribableChannel input();
|
||||
|
||||
@Input("input2")
|
||||
SubscribableChannel input2();
|
||||
|
||||
@Input("input3")
|
||||
SubscribableChannel input3();
|
||||
}
|
||||
}
|
||||
+15
-15
@@ -2,38 +2,38 @@ package com.rocketmq.demo.service;
|
||||
|
||||
import com.rocketmq.demo.model.Order;
|
||||
|
||||
import org.springframework.cloud.stream.annotation.StreamListener;
|
||||
import org.springframework.cloud.stream.messaging.Sink;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author zlt
|
||||
*/
|
||||
@Service
|
||||
@Configuration
|
||||
public class ReceiveService {
|
||||
/**
|
||||
* 字符串消息
|
||||
*/
|
||||
@StreamListener(Sink.INPUT)
|
||||
public void receiveInput(String receiveMsg) {
|
||||
System.out.println("input receive: " + receiveMsg);
|
||||
@Bean
|
||||
public Consumer<String> receiveInput() {
|
||||
return receiveMsg -> System.out.println("input receive: " + receiveMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象消息
|
||||
*/
|
||||
@StreamListener("input2")
|
||||
public void receiveInput2(@Payload Order order) {
|
||||
System.out.println("input2 receive: " + order);
|
||||
@Bean
|
||||
public Consumer<Order> receiveInput2() {
|
||||
return order -> System.out.println("input2 receive: " + order);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过spring.messaging对象来接收消息
|
||||
*/
|
||||
@StreamListener("input3")
|
||||
public void receiveInput3(Message msg) {
|
||||
System.out.println("input3 receive: " + msg);
|
||||
}
|
||||
@Bean
|
||||
public Consumer<Message<String>> receiveInput3() {
|
||||
return msg -> System.out.println("input3 receive: " + msg);
|
||||
}
|
||||
}
|
||||
@@ -6,34 +6,35 @@ spring:
|
||||
name: rocketmq-produce
|
||||
cloud:
|
||||
stream:
|
||||
rocketmq:
|
||||
binder:
|
||||
# RocketMQ 服务器地址
|
||||
name-server: 192.168.28.130:9876
|
||||
bindings:
|
||||
input2:
|
||||
consumer:
|
||||
#增加tag过滤
|
||||
tags: tagObj
|
||||
function:
|
||||
definition: receiveInput;receiveInput2;receiveInput3
|
||||
bindings:
|
||||
input:
|
||||
receiveInput-in-0:
|
||||
destination: test-topic
|
||||
content-type: text/plain
|
||||
group: consume-group1
|
||||
consumer:
|
||||
#并发消费线程数
|
||||
concurrency: 20
|
||||
input2:
|
||||
receiveInput2-in-0:
|
||||
destination: test-topic
|
||||
content-type: application/json
|
||||
group: consume-group2
|
||||
consumer:
|
||||
#并发消费线程数
|
||||
concurrency: 20
|
||||
input3:
|
||||
receiveInput3-in-0:
|
||||
destination: test-topic
|
||||
content-type: text/plain
|
||||
group: consume-group3
|
||||
consumer:
|
||||
#并发消费线程数
|
||||
concurrency: 20
|
||||
concurrency: 20
|
||||
rocketmq:
|
||||
binder:
|
||||
# RocketMQ 服务器地址
|
||||
name-server: 192.168.28.130:9876
|
||||
|
||||
logging:
|
||||
level:
|
||||
org.springframework.context.support: debug
|
||||
Reference in New Issue
Block a user