在 Camel 路由上使用自定义 JMS 侦听器的 "containerFactory"
Use a custom JMS listener's "containerFactory" on a Camel route
我想使用 Camel 路由接收消息,但能够以某种方式注入自定义“containerFactory”。
通常(没有骆驼路线),你会做这样的事情:
@JmsListener(destination = "${some.virtual-topic.queue}",
containerFactory = "customJmsListenerContainerFactory")
public void receiveMessage(String message) throws Exception {
// do something cool with the received message ...
}
请注意上面“JmsListener”注释的“containerFactory”属性 如何为我们提供使用非默认“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 containerFactory。有人知道这是否可能(以非黑客方式)吗?或者如果没有,那么我们将不得不依赖标准的监听器。
查看文档:https://camel.apache.org/components/latest/activemq-component.html
选项 consumerType
应设置为 Custom
并且 messageListenerContainerFactory
应引用容器工厂实现的 bean id。
我想使用 Camel 路由接收消息,但能够以某种方式注入自定义“containerFactory”。
通常(没有骆驼路线),你会做这样的事情:
@JmsListener(destination = "${some.virtual-topic.queue}",
containerFactory = "customJmsListenerContainerFactory")
public void receiveMessage(String message) throws Exception {
// do something cool with the received message ...
}
请注意上面“JmsListener”注释的“containerFactory”属性 如何为我们提供使用非默认“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 containerFactory。有人知道这是否可能(以非黑客方式)吗?或者如果没有,那么我们将不得不依赖标准的监听器。
查看文档:https://camel.apache.org/components/latest/activemq-component.html
选项 consumerType
应设置为 Custom
并且 messageListenerContainerFactory
应引用容器工厂实现的 bean id。