rocketmq学习(三)-springcloud stream rocketmq 函数式编程实现

Maven添加依赖

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
    <version>${spring-cloud-starter-stream-rocketmq.version}</version>
</dependency>

yml配置

消费者和生产者的使用方式为:名称-out-数字的方式用于生产者,名称-in-数字的方式用于消费者。

spring:
	cloud:
	    function:
	      definition: receive1;receive2;receive3  #重点配置 与 binding 名与消费者对应,多个可以使用;
	    stream:
	      rocketmq:
	        binder:
	          name-server: 127.0.0.1:9876  #rocketmq 地址
	          vipChannelEnabled: false
	        bindings:
	          receive1-in-0:
	            consumer:
	              tags: s1||s2  #消费tag
	              broadcasting: false #是否使用广播消费,默认为 false 使用集群消费
	          receive1-out-0:
	            producer:
	              sync: true  #开启同步发送
	          receive2-in-0:
	            consumer:
	              tags:   #消费tag
	              broadcasting: true # 是否使用广播消费,默认为 false 使用集群消费
	          receive2-out-0:
	            producer:
	              sync: false #默认异步
	          receive3-in-0:
	            consumer:
	              tags:   #消费tag
	              broadcasting: false # 是否使用广播消费,默认为 false 使用集群消费
	          receive3-out-0:
	            producer:
	              sync: true
	
	      bindings:
	        #消费者
	        receive1-in-0:
	          destination: receive1-topic 	#topic
	          content-type: application/json
	          group: receive1-in-group 	#group
	        #生产者
	        receive1-out-0:
	          destination: receive1-topic #topic
	          group: receive1-out-group
	        receive2-in-0:
	          destination: receive2-topic #topic
	          content-type: application/json
	          group: receive2-in-group #group
	        receive2-out-0:
	          destination: receive2-topic #topic
	          group: receive2-out-group
	        receive3-in-0:
	          destination: receive3-topic #topic
	          content-type: application/json
	          group: receive3-in-group #group
	        receive3-out-0:
	          destination: receive3-topic #topic
	          group: receive3-out-group #group

生产者发生消息

@RestController
@RequestMapping("/stream")
@RequiredArgsConstructor
@Slf4j
public class StreamController {
   

    
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值