1 2 3 4 5 6 7 8 9 10 11 |
//设置ack 模式未客户端确认 headers.setAck("client"); subscription = session.subscribe(headers, new MessageHandler(session, null) ); //使用NACK帧告诉broker,消费失败,请求其重新投递 StompHeaders ackHeaders = new StompHeaders(); ackHeaders.setMessageId(headers.getMessageId()); ackHeaders.set("subscription", subscription.getSubscriptionId()); subscription.getSubscriptionId(); session.acknowledge(ackHeaders, true); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<plugins> <redeliveryPlugin fallbackToDeadLetter="true" sendToDlqIfMaxRetriesExceeded="true"> <redeliveryPolicyMap> <redeliveryPolicyMap> <redeliveryPolicyEntries> <redeliveryPolicy queue="javacodercn" maximumRedeliveries="4" redeliveryDelay="10000" initialRedeliveryDelay="5000" useExponentialBackOff="true"/> </redeliveryPolicyEntries> </redeliveryPolicyMap> </redeliveryPolicyMap> </redeliveryPlugin> </plugins> |
useExponentialBackOff 表示使用指数延时,时间分别为5s, 25s, 125s
Posted in: spring practise
Comments are closed.