我希望使用Camel路由接收消息,但要能够以某种方式注入自定义的"containerfactory"
通常(没有Camel路由),您会这样做:
@JmsListener(destination = "${some.virtual-topic.queue}",
containerFactory = "customJmsListenerContainerFactory")
public void receiveMessage(String message) throws Exception {
// do something cool with the received message ...
}
请注意"containerFactory"JmsListener"属性上面的注释为我们提供了一种使用非默认"containerfactory"的方法。这很好,但是如果我们想使用Camel路由从队列中读取数据呢?比如:
@Component
public class TestRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("activemq:queue:{{some.virtual-topic.queue}}")
.bean(MessageFacade.class, "process");
}
}
在上面这个最新的例子中,我无法"注入"自定义JMS容器工厂。有人知道这是可能的(在一个非黑客的方式)吗?否则,我们将不得不依赖标准侦听器。
参见文档:https://camel.apache.org/components/latest/activemq-component.html
选项consumerType
应设置为Custom
,messageListenerContainerFactory
应参考您的容器工厂实现的bean id。