0

2020欧洲杯时间表I got a producer:

rabbitTemplate.convertAndSend(QueueConstants.PROVISIONING_EXCHANGE, QueueConstants.PROVISIONING_ROUTING_KEY, message);

And my config:

@Bean
Queue organizationProvisioningQueue() {
    return QueueBuilder.durable(QueueConstants.PROVISIONING_QUEUE)
            .withArgument("x-dead-letter-exchange", "")
            .withArgument("x-dead-letter-routing-key", QueueConstants.DEAD_LETTER_QUEUE)
            .build();
}

@Bean
Queue deadLetterQueue() {
    return QueueBuilder.durable(QueueConstants.DEAD_LETTER_QUEUE).build();
}

@Bean
DirectExchange exchange() {
    return new DirectExchange(QueueConstants.PROVISIONING_EXCHANGE);
}

@Bean
Binding binding() {
    return BindingBuilder.bind(organizationProvisioningQueue()).to(exchange()).with(QueueConstants.PROVISIONING_ROUTING_KEY);
}

and my message processor:

@RabbitListener(queues = QueueConstants.PROVISIONING_QUEUE)
public void process(ProvisioningMessage message) throws ProvisioningException {
    System.out.println("Processing " + message);

    throw new ProvisioningException ("Some ex " + message);
}

And the constants:

public static final String PROVISIONING_EXCHANGE = "provisioning-exchange";
public static final String PROVISIONING_ROUTING_KEY = "provisioning";
public static final String PROVISIONING_QUEUE = "provisioning-queue";

public static final String DEAD_LETTER_QUEUE = PROVISIONING_QUEUE + ".dlq";

The dead letter queue doesn't work as the message gets re-queued every time after the exception is thrown resulting in an infinite loop instead of going to the dead-letter-queue.

I've changed my queue name to end in .dlq as well since it was suggested but still no success. What am I doing wrong?

0

You need to either throw an AmqpRejectAndDontRequeueException or set the listener container's defaultRequeueRejected property to false.

2020欧洲杯时间表The name of the dlq is irrelevant.

| improve this answer | |
  • First option is not what I want since I want to do an exponential backoff when errors are thrown so only the 5th request would go to dlq, and for the second I set spring.rabbitmq.listener.default-requeue-rejected= false in my application.properties but still the messages get infinitely re-queued. – Fofole Mar 18 at 11:00
  • That makes no sense to me; something must be wrong. However, if you are using retry, you can configure an RejectAndDontRequeueRecoverer into the retry interceptor and it will reject the message when retries are exhausted. – Gary Russell Mar 18 at 13:58
0

2020欧洲杯时间表Recently I had similiar problem (infinite requeue of message in case of Exception). In my case setting up of this application property solved problem:

spring.rabbitmq.listener.simple.default-requeue-rejected=false
| improve this answer | |
0

Poison message handling in RabbitMQ it is available as of RabbitMQ 3.8.0, by using the new type of queue: Quorum Queues.

Quorum queue support handling of poison messages, that is, messages that cause a consumer to repeatedly requeue a delivery (possibly due to a consumer failure) such that the message is never consumed completely and positively acknowledged so that it can be marked for deletion by RabbitMQ.

2020欧洲杯时间表Be aware, some features are not currently supported by quorum queues:

Quorum queues keep track of the number of unsuccessful delivery attempts and expose it in the "x-delivery-count" header that is included with any redelivered message.

It is possible to set a delivery limit for a queue using a policy argument, delivery-limit. When a message has been returned more times than the limit the message will be dropped or dead-lettered (if a DLX is configured).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy2020欧洲杯时间表

Not the answer you're looking for? Browse other questions tagged or ask your own question.