【问题标题】:Use a custom JMS listener's "containerFactory" on a Camel route在 Camel 路由上使用自定义 JMS 侦听器的“containerFactory”
【发布时间】:2021-04-23 14:10:18
【问题描述】:

我想使用 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。有谁知道这是否可能(以非黑客方式)?否则,我们将不得不依赖标准侦听器。

【问题讨论】:

    标签: spring-boot apache-camel spring-jms


    【解决方案1】:

    查看文档:https://camel.apache.org/components/latest/activemq-component.html

    选项consumerType 应设置为CustommessageListenerContainerFactory 应引用容器工厂实现的bean id。

    【讨论】:

    • Claus 非常感谢您向我指出相关文档,甚至提出了解决方案!祝你有美好的一天
    猜你喜欢
    • 1970-01-01
    • 2013-03-08
    • 1970-01-01
    • 2013-10-09
    • 2015-04-22
    • 2021-07-20
    • 2019-05-04
    • 1970-01-01
    • 2019-03-24
    相关资源
    最近更新 更多