繁体   English   中英

使用 spring 云 stream 兔子 mq binder 在 header 中发送消息 TTL

[英]Send message TTL in header using spring cloud stream rabbit mq binder

我想将 spring 云 stream rabbitMQ 活页夹用于消息驱动的架构。 但是每条消息都应该有自己的生存时间设置。 所以我需要在消息 header 中给出这个设置。 您认为使用 Spring Cloud Stream RabbitMQ Binder 是否可行?

   Message message1 = MessageBuilder.withPayload(new PFSimulationEvent(1, "sd"))
            .setHeader("to_process", true).setHeader("expiration", 10000)
            .build();
        output.send("simulatePf-out-0", message1);

是的,您可以通过多种方式做到这一点 - https://docs.spring.io/spring-cloud-function/docs/current/reference/html/spring-cloud-function.html#_inputoutput_enrichment最新添加是通过input/output-header-mapping-expression

此功能与 binder 无关,因为它位于 spring-cloud-function 级别,并且可以与任何 binder 一起使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM