根据主体内容在JMS中进行过滤 [英] Filtering in JMS based on body content

查看:97
本文介绍了根据主体内容在JMS中进行过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JMS实现发布/订阅模型.我从Pub向所有订阅者发送了一条消息.我希望订阅者应基于实际邮件正文中的某些字符串来获取经过过滤的邮件.

I m implementing Pub/Sub model using JMS. I send a message from Pub to all Subscribers. I want that subscribers should get filtered messages based on some string in actual message body.

例如,订户订阅了主题体育",并且应该只接收在消息文本正文中具有关键字板球"的帖子.

For example a subscriber subscribe to a topic 'sports' and should receive only those posts which has keyword 'cricket' in it in the message text body.

p.s.我不想使用消息选择器.

p.s. I dont want to use message selectors.

我该如何实现.

感谢和问候.

推荐答案

您不能使用任何机制根据邮件正文内容过滤主题上的邮件.通常, JMS选择器用于过滤邮件,但即使这样对正文内容也无效:

You can use no mechanism for filtering messages on a topic based on the Message Body contents. Usually a JMS Selector is used for filtering messages but even this does not work for Body Contents:

来自 Java EE 6教程:

A 邮件选择器无法根据邮件正文的内容选择邮件..

A message selector cannot select messages on the basis of the content of the message body..

这里的问题是,您必须先接收(即消费)消息,然后提取其消息内容,以免出现任何形式的正文过滤".

The issue here is that you have to first receive (that is consume) the message and then extract its contents which precludes the case of any kind of Body filtering.

这篇关于根据主体内容在JMS中进行过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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