Spring AMPQ - 创建过期的队列 Bean

Spring AMPQ - Create Queue Bean with expiration

我应该如何创建一个 RabbitMQ 队列作为一个带有消息过期设置的基于注解的 Bean?以下代码似乎不起作用。

    @Bean()
public Queue theQueue(){
    Map<String, Object> args = new HashMap<>();
    args.put("x-message-ttl", "60000");
    return new Queue(MessageConstants.QUEUE, true, false, false, args);
}

它创建了一个队列,但没有为消息设置过期时间

必须是数值;尝试

args.put("x-message-ttl", 60000);

如果队列已经存在且没有参数;你需要先删除它。