SpringCloud DataFlow — 5. 多分支负载

SpringCloud DataFlow — 0. 本地部署部署
SpringCloud DataFlow — 1. 自定义Processor
SpringCloud DataFlow — 2. 自定义Sink
SpringCloud DataFlow — 3. 暴露properties
SpringCloud DataFlow — 4. Prometheus + Grafana 监控
SpringCloud DataFlow — 5. 多分支负载

1. 目的

通过分支部署, 起到负载的效果, 提升处理速度

2. 示例

在这里插入图片描述

3. 导入jar

app import --uri https://dataflow.spring.io/kafka-maven-latest
app register --type processor --name unpack --uri maven://etl.dmt.quick:unpack-processor-kafka:0.0.1-SNAPSHOT
app register --type processor --name clean --uri maven://etl.dmt.quick:clean-processor-kafka:0.0.1-SNAPSHOT
app register --type sink --name storage --uri maven://etl.dmt.quick:storage-sink-kafka:0.0.1-SNAPSHOT

4. 两种方式

4.1 多分支部署
4.1.1 创建流
stream create --name main --definition "http --path-pattern=/quick --port=9000 | unpack | clean | storage"
stream create --name sub --definition ":main.unpack > clean | storage"
4.1.2 部署流
stream deploy --name main --properties "app.clean.spring.cloud.stream.bindings.input.group=quick,app.unpack.spring.cloud.stream.bindings.output.producer.partitionCount=2"
stream deploy --name sub --properties "app.clean.spring.cloud.stream.bindings.input.group=quick"
4.2 多实例部署
4.2.1 创建流
stream create --name main --definition "http --path-pattern=/quick --port=9000 | unpack | clean | storage"
4.2.2 部署流
stream deploy --name main --properties "deployer.clean.count=2, deployer.storage.count=2"

5. 测试

5.1 查看kafka
bin/kafka-topics.sh --zookeeper localhost:2181 --topic main.unpack --describe

Topic:main.unpack	PartitionCount:2	ReplicationFactor:1	Configs:
	Topic: main.unpack	Partition: 0	Leader: 0	Replicas: 0	Isr: 0
	Topic: main.unpack	Partition: 1	Leader: 0	Replicas: 0	Isr: 0
5.2 发送http请求, 并查看日志
1. 打开dashboard (http://localhost:9393/dashboard)
2. 切换至Runtime
3. 点击 "main.clean-v1-0", 其中 stdout 即为日志文件目录, 使用tail -f 命令查看
4. 同上 "sub.clean-v1-0"
5. 发送http请求, 例如使用curl 
    curl -H "Content-Type:application/json" -X POST --data '{"message": "hello world"}' http://localhost:9000/quick

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值