我无法使用 spring amp quot 组织延迟发送消息

I can't organize delayed sending of messages with spring amp quot

配置class(部分):

 public static RabbitQueueConfig clubProNotAvailableConfig =
  new RabbitQueueConfig("club-pro-not-available", "club-pro-not-available", "club-pro-not-available-status", "3-3");

    @Bean
    public SimpleMessageListenerContainer listenerContainer5(ClubProNotAvailableListener listener, ConnectionFactory connectionFactory) {
        return initListenerContainer(listener, clubProNotAvailableConfig, connectionFactory);
    }


    private SimpleMessageListenerContainer initListenerContainer(
            ChannelAwareMessageListener listener,
            RabbitQueueConfig config,
            ConnectionFactory connectionFactory
    ) {
        SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer();
        listenerContainer.setConnectionFactory(connectionFactory);
        listenerContainer.setQueueNames(config.getQueue());
        listenerContainer.setMessageListener(listener);
        listenerContainer.setAcknowledgeMode(AcknowledgeMode.MANUAL);
        listenerContainer.setConcurrency(config.getThreadPoolSize());
        listenerContainer.setPrefetchCount(1);
        return listenerContainer;
    }

发送消息的方法:

   try {
        success = clientRepository.updateAnketa(privatePersonProfile.getProfileId(), clubProAnketa, null);
        } catch (ClubProNotAvailableException e) {


            ClubProNotAvailableRabbit clubProNotAvailableRabbit = new ClubProNotAvailableRabbit();
            clubProNotAvailableRabbit.setRequestContextRabbit(RequestContextRabbit.createContext(requestContextService.getContext()));
            clubProNotAvailableRabbit.setCountRetry(0L);
            clubProNotAvailableRabbit.setProfileId(privatePersonProfile.getProfileId());
            clubProNotAvailableRabbit.setNameMethod(ChangeMethod.CHANGE_ANKETA);
            clubProNotAvailableRabbit.setChangeAnketaData(anketa);

   rabbitTemplate.convertAndSend(config.getExchange(), config.getRoutingKey(), clubProNotAvailableRabbit, new MessagePostProcessor() {
                @Override
                public Message postProcessMessage(Message message) throws AmqpException {
                    message.getMessageProperties().setHeader("x-delay", 10000);
                    return message;
                }
            });

            throw new ClubProNotAvailableException();
        }

代理中的配置:

队列配置:

交换机配置:

我已阅读文档,尝试了几个选项,但无法将其应用到我的代码中。

我做错了什么?我将非常感谢你的帮助。

您好像没有延迟交换插件;您还已将交换声明为简单的 fanout;交易所应该是这样的:

另外,要设置发送时的延迟,您应该使用:

        template.convertAndSend(exchangeName, queue.getName(), "foo", message -> {
            message.getMessageProperties().setDelay(1000);
            return message;
        });