Camel 3 - Dynamic uri for deadLetterChannel

167 views Asked by At

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;      
}
0

There are 0 answers