1

I'm trying to setup a smart JMS deadLetterChannel where the final uri of the DLQ is computed dynamically, depending on original queue name (eg adding a ".dead" suffix).

I have seen in the doc that it's possible by setting the CamelJmsDestinationName header.

Therefore, I tried this:

DefaultErrorHandlerBuilder dlc = deadLetterChannel("jms:queue:dummy")
            .useOriginalMessage()
            .maximumRedeliveries(2);                
dlc.onPrepareFailure( exchange -> {
     // Override destination                                
     exchange.getMessage().setHeader("CamelJmsDestinationName", "jms:queue:test");                   
});

I have tried many different values for CamelJmsDestinationName :

  • "jms:queue:test"
  • "queue:test"
  • "test"

But none of them is working; the header is ignored and the exchange always goes to original uri ("queue:dummy").

What am I doing wrong ??

I'm using Camel 3.6 and camel-sjms2 component bound to an Artemis ActiveMQ broker:

@Resource(mappedName = "java:/ConnectionFactory")
private static ConnectionFactory connectionFactory; 


@Produces
@ApplicationScoped
@Named("jms")
public final Sjms2Component createJmsComponent() {
    Sjms2Component component = new Sjms2Component();
    ConnectionResource pool = new ConnectionFactoryResource(poolSize, connectionFactory);
    component.setConnectionResource(pool);
    return component;      
}
TacheDeChoco
  • 3,683
  • 1
  • 14
  • 17
  • 1
    I normally set this up on the broker. AMQ/Artemis allows you to create individual dead letter queues. Thus is you have a queue called foo then the broker will create a DLQ.foo queue when a message on queue foo fails. An example is here https://tuhrig.de/effective-error-handling-for-activemq-topics/ – Namphibian Nov 25 '20 at 00:28

0 Answers0