【问题标题】:How to filter jms message in apache camel xml configuration file如何在 apache camel xml 配置文件中过滤 jms 消息
【发布时间】:2018-05-16 02:37:23
【问题描述】:

我希望创建一个关于一般主题的 jms 订阅者。为了避免不需要的消息,我希望在那里创建一个过滤器。问题是语法在java代码的每个地方都可用,但我找不到如何在像blueprint.xml这样的xml配置文件中做同样的事情

Java 代码

String redSelector = "color='red'";
MessageConsumer redConsumer = redSession.createConsumer(queue, redSelector);

阿帕奇骆驼路线

<route id="externalNotificationsDispatchRoute" >
  <from uri="activemq:queue:{{vqueue.name}}" />
  .. filtering part
  <to uri="log:com?level=DEBUG" />
</route>

【问题讨论】:

    标签: apache-camel activemq camel-jms


    【解决方案1】:

    使用selector URI 参数指定JMS 消息选择器。

    蓝图:

    <from uri="activemq:queue:{{vqueue.name}}?selector={{vqueue.selector}}" />
    

    属性文件:

    vqueue.selector=color%3D'red'
    

    参考JMS component documentation(ActiveMQ组件继承JMS组件的参数)

    选择器

    设置 JMS 选择器,这是一个 SQL 92 谓词,用于过滤代理中的消息。您可能必须将特殊字符(如“=”)编码为 %3D。

    【讨论】:

    • 谢谢。它正在工作。
    猜你喜欢
    • 2017-04-24
    • 1970-01-01
    • 2014-12-30
    • 1970-01-01
    • 2019-06-03
    • 2014-03-12
    • 2023-04-01
    • 2019-10-12
    • 2023-03-19
    相关资源
    最近更新 更多