RabbitMQ delayed received message achieved by DLX

1. Create WorkQueue queue, and the binding WorkQueue with exchangeWork;
2. Create a queue DLXQueue, and the binding DLXQueue with exchangeDLX;
A queue parameter set DLXQueue:.
X-Dead Letter-to-Exchange DLXQueue
X-Message-TTL 5000 milliseconds
3. set WorkQueue and DLXQueue two key exchange routes are DLXQueue (default)
4. set exchangeDLX binding exchangeWork, the route key is DLXQueue.

研华
spring 配置示例:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.1.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd ">
IPC
<! - defined rabbitmq connection factory, production environments cluster configuration to support failover ->

<rabbit:connection-factory id="connectionFactory" publisher-confirms="true" addresses="${rabbitmq.host}" />

<rabbit:admin connection-factory="connectionFactory"/>

<bean id="jsonMessageConverter" class="org.springframework.amqp.support.converter.JsonMessageConverter">
<property name="classMapper">
<bean class="org.springframework.amqp.support.converter.DefaultClassMapper"/>
</property>
</bean>

<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" message-converter="jsonMessageConverter"/>

Guess you like

Origin www.cnblogs.com/j950523/p/11764177.html