rabbitmq using the delay abnormal Times

Times abnormal delay switch statement (unknown exchange type 'x-delayed-message') solution

The server needs to download and install the plug-in:

1. Download the plugin package

2. After downloading the plug-in installation packages to a directory service

rpm -ql rabbitmq-server queries installation position
at the end of the downloaded files to ez / plugins / directory

3. Start Plug

        [root@localhost plugins]# rabbitmq-plugins enable rabbitmq_delayed_message_exchange
        [root@localhost plugins]# systemctl restart rabbitmq-server.service

4. Add head when sending message

        rabbitTemplate.convertAndSend("test_publish_exchange",routingKey,content,new MessagePostProcessor() {
                    @Override
                    public Message postProcessMessage(Message message) throws AmqpException {
                        //设置消息持久化
                        //message.getMessageProperties().setDeliveryMode(MessageDeliveryMode.PERSISTENT);
                        //message.getMessageProperties().setHeader("x-delay", "6000");
                        message.getMessageProperties().setDelay(6000);
                        return message;
                    }
                });

 

Guess you like

Origin www.cnblogs.com/lantuanqing/p/11289107.html