Rocketmq 使用延迟队列

spring-cloud-stream-binder-rocketmq 不支持延时队列,需要使用原生的mq进行消息发送。

一、引入依赖

 implementation 'com.alibaba.cloud:spring-cloud-stream-binder-rocketmq:2.1.0.RELEASE'

二、定义生产信道和消费信道

//消费信道
public interface PagePointSink {
   
    String PAGE_POINT_INPUT = "page_point_input";

    @Input(PAGE_POINT_INPUT)
    SubscribableChannel pagepointInput();
}

//生产信道
public interface PagePointSource {
   
    String PAGE_POINT_OUTPUT = "page_point_output";

    @Output(PAGE_POINT_OUTPUT)
    MessageChannel pagepointOutput();
}

三、配置文件配置

spring.cloud.stream.bindings.page_point_output.destination=page_point
spring.cloud.stream.bindings.page_point_output.content-type=application/json
spring.cloud.stream.bindings.page_point_input.destination=page_point
spring.cloud.stream.bindings.page_point_input.content-type=application/json
spring.cloud.stream.bindings.page_point_input.group=page_point_input

四、延时发送

1、生产端

import java.util.Date;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值