博客
关于我
Spring Cloud Stream:消费失败后的处理策略(一):自动重试
阅读量:87 次
发布时间:2019-02-26

本文共 1955 字,大约阅读时间需要 6 分钟。

Spring Cloud Stream??????????

????

????????????????????????????????Spring Cloud Stream????????????????????????????????????????????????????????????????

????

???????????????Spring Cloud Stream???????????????????????

@EnableBinding(TestApplication.TestTopic.class)@SpringBootApplicationpublic class TestApplication {    public static void main(String[] args) {        SpringApplication.run(TestApplication.class, args);    }}@RestControllerstatic class TestController {    @Autowired    private TestTopic testTopic;    @GetMapping("/sendMessage")    public String messageWithMQ(@RequestParam String message) {        testTopic.output().send(MessageBuilder.withPayload(message).build());        return "ok";    }}@Slf4j@Componentstatic class TestListener {    @StreamListener(TestTopic.INPUT)    public void receive(String payload) {        log.info("Received: " + payload);        throw new RuntimeException("Message consumer failed!");    }}interface TestTopic {    String OUTPUT = "example-topic-output";    String INPUT = "example-topic-input";    @Output(OUTPUT)    MessageChannel output();    @Input(INPUT)    SubscribableChannel input();}

????

????????????????????????

spring.cloud.stream.bindings.example-topic-input.destination=test-topicspring.cloud.stream.bindings.example-topic-output.destination=test-topic

????????localhost:8080/sendMessage?message=hello????????????????????????

2018-12-10 11:20:21.345 INFO ... Received: hello2018-12-10 11:20:22.350 INFO ... Received: hello2018-12-10 11:20:24.354 INFO ... Received: hello2018-12-10 11:20:54.651 ERROR ... Message consumer failed!

??????????3??

??????

??????Spring Cloud Stream???3???????????????

spring.cloud.stream.bindings.example-topic-input.consumer.max-attempts=1

????????????????????????0???????????????

????

??????????????????

????????????????????????????????????????

????????????

????????????????????????????????????????????????

????

????????????stream-exception-handler-1?????????????

转载地址:http://endz.baihongyu.com/

你可能感兴趣的文章
PNETLab 镜像包官方下载太慢?不急,最新版本PNET_4.2.10分享!
查看>>
POCO库中文编程参考指南(4)Poco::Net::IPAddress
查看>>
Quartz基本使用(二)
查看>>
POC项目安装与使用指南
查看>>
Podman核心技术详解
查看>>
pods 终端安装 第三方框架的一些命令
查看>>
Podzielno
查看>>
PoE、PoE+、PoE++ 三款交换机如何选择?一文带你了解
查看>>
PoE三种标准:标准 PoE、PoE+、PoE++,网络工程师必知!
查看>>
POI 的使用
查看>>
poi 读取单元格为null者空字符串
查看>>
poi-tl简介与文本/表格和图片渲染
查看>>
pointnet分割自己的点云数据_PointNet解析
查看>>
POI实现Excel导入Cannot get a text value from a numeric cell
查看>>
POI实现Excel导入时提示NoSuchMethodError: org.apache.poi.util.POILogger.log
查看>>
POI实现Excel导出时常用方法说明
查看>>
POI导出Excel2003
查看>>
POI数据获取及坐标纠偏
查看>>
Quartz入门看这一篇文章就够了
查看>>
POI解析Excel【poi的坑——空行处理】
查看>>