0
votes

I'd like to receive messages using a Camel route, but having the capability to somehow inject a custom "containerFactory".

Usually (without a Camel route), you'd do something like:

@JmsListener(destination = "${some.virtual-topic.queue}", 
containerFactory = "customJmsListenerContainerFactory")
public void receiveMessage(String message) throws Exception {
  // do something cool with the received message ...
}

Note how the "containerFactory" property of the "JmsListener" annotation above provides us with a way of using a non default "containerFactory". That works fine, but what if instead we'd like to use a Camel route for reading from the queue? Something like:

@Component
public class TestRoute extends RouteBuilder  {
    
    @Override
    public void configure() throws Exception {
        from("activemq:queue:{{some.virtual-topic.queue}}")
            .bean(MessageFacade.class, "process");
    } 
}

In this latest case above, I've not been able to "inject" a custom JMS containerFactory. Does anybody knows if this is possible (in a non-hack way)? or if not then we'll have to rely on the standard listener.

1

1 Answers

1
votes

See the documentation: https://camel.apache.org/components/latest/activemq-component.html

The options consumerType should be set to Custom and messageListenerContainerFactory should refer to the bean id of your container factory implementation.