Apache MQ-JMS消息选择器 [英] Apache MQ - JMS message selector

查看:126
本文介绍了Apache MQ-JMS消息选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助来获取具有特定属性的特定队列的所有消息.

I need some help to fetch all the messages for a particular queue which has a particular property on it.

这里的问题是我需要将JMS标头属性 process processName 匹配.由于消息的process值可以为大写或小写,而processName始终为大写的值.

The problem here is I need to match the JMS header property process with processName.As the message can have the value for process as upper or lowercase but processName always has a value which is uppercase.

我不能不能在这里使用equalsIgnorecase,例如: StringJMSCriteriaBuilder("process").equalIgnorecase(processName);

I can NOT use equalsIgnorecase here like : StringJMSCriteriaBuilder("process").equalIgnorecase(processName);

由于IJMSSelectorCriteriaBuilder界面中没有此类方法.

As there is no such method in IJMSSelectorCriteriaBuilder interface.

下面是我当前拥有的代码:

Below is the code I have currently:

private String createJMSSelectorMessage(QueueFilter queueFilter) throws Exception {
        StringBuffer selectorMessage = new StringBuffer();
        String processName=Service.getProcess(Long.valueOf(queueFilter.getProcess())).getProcessName();


        IJMSSelectorCriteriaBuilder processNameSelectorCriteriaBuilder = new StringJMSCriteriaBuilder("process").eq(processName);
        selectorMessage.append(processNameSelectorCriteriaBuilder.getJMSSelectorCriteriaValue());
        return selectorMessage;
        }

推荐答案

JMS规范规定选择器区分大小写.

The JMS specification stipulates that selectors are case sensitive.

当且仅当两个字符串包含相同的字符序列时,两个字符串才相等.

Two strings are equal if and only if they contain the same sequence of characters.

我见过的解决方案包括:

Solutions I have seen used include:

  • 预处理所有消息以规范大小写
  • 使用Message Broker
  • 浏览,评估代码并选择
  • 让程序将消息规范化大小写放在首位

对不起,没有一个好的接收方解决方案不涉及解析每条消息.

Sorry, there's no good receiver-side solution that doesn't involve parsing every message.

这篇关于Apache MQ-JMS消息选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆