camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From souciance <souciance.eqdam.ras...@gmail.com>
Subject Re: Use dead letter with RabbitMQ after N retries
Date Wed, 28 Jun 2017 10:37:01 GMT
What error message do you get from Rabbit when you try to send it to the
dead letter exchange?

It depends. It can created for the first time if you set certain properties
to true. It can assume the exchange exists and create it if those
properties are set to false.

Look at the properties, autoDelte, durable, skipExchangeDeclare.

On Wed, Jun 28, 2017 at 12:11 PM, jdiego_reyes [via Camel] <
ml+s465427n5805291h84@n5.nabble.com> wrote:

> Hi all,
>
> We are involved in a RabbitMQ - Camel integration with the Akka-camel
> library, so that we need the following:
>
> - Receive a message with a Camel Consumer Actor
> - If something goes wrong (e.g. an Exception is thrown), requeue the
> message
> - After 3 times failing, redirect the message to a dead letter exchange
>
> To achieve that, we've defined a Routedefinition for our Consumer actor
> (UntypedConsumerActor). The part of requeing is working, but the dead
> letter redirection is not working yet. I'm sharing you the piece of code
> where we are defining the route definition:
>
> @Override
> public Mapper<RouteDefinition, ProcessorDefinition<?>>
> getRouteDefinitionHandler() {
>    return mapper;
> }
>
> private Mapper<RouteDefinition, ProcessorDefinition<?>> mapper =
>       new Mapper<RouteDefinition, ProcessorDefinition<?>>() {
>
>          final class Log extends Exception implements Processor {
>
>             private static final long serialVersionUID =
> 7257368354387465748L;
>
>             @Override
>             public void process(Exchange exchange) {
>                logger.error(
>                      null,
>                      "There is an error with message: {0}, and it exceeds
> the redelivering maximum counter.",
>                      exchange );
>
>             }
>          }
>
>          @Override
>          public ProcessorDefinition<?> apply(RouteDefinition rd) {
>             loadCronScheduledRoutePolicy( rd );
>
>             //We define a routedefinition in case of exception because the
> messages should be requeue on the broker for a maxnumretry
>             if(deadLetterExchange != null && deadLetterRoutingKey != null)
> {
>                rd
>                      .setHeader(RabbitMQConstants.RABBITMQ_DEAD_LETTER_EXCHANGE,
> new org.apache.camel.model.language.ConstantExpression(deadLetterExchange))
>
>                      .setHeader(RabbitMQConstants.
> RABBITMQ_DEAD_LETTER_ROUTING_KEY,
>                            new org.apache.camel.model.
> language.ConstantExpression(deadLetterRoutingKey));
>             }
>
>             return rd
>             .onException( Exception.class )
>             .maximumRedeliveries( maxnumretry )
>             .redeliveryDelay( 0 )
>             .setHeader( RabbitMQConstants.REQUEUE,
>                   new org.apache.camel.model.language.ConstantExpression(
> "TRUE" ) )
>             .handled( true )
>             .process( new Log() )
>             .end();
>          }
>       };
>
>
> Our dead letter exchange is of type 'direct' and its routing key is '#',
> the same as the queue we are consuming.
>
> Is the dead letter exchange created when the error occurs for the first
> time? Do we need to create the exchange before defining this
> routedefinition?
>
> Thanks in advance!!!
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Use-dead-letter-with-
> RabbitMQ-after-N-retries-tp5805291.html
> To start a new topic under Camel - Users, email ml+s465427n465428h31@n5.
> nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Use-dead-letter-with-RabbitMQ-after-N-retries-tp5805291p5805293.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message