开发者

JMS Message Selector implementation

I need to verify whether javax.jms.Message matches provided selector i.e.:

Message msg = ...;
SomeSelectorMatcher matcher = new SomeSelectorMatcher(" someProp='someVal' and开发者_StackOverflow someProp2 >3 ... ");

if(matcher.matches(msg){
     //do sth
}else{
     //do sth else
}

Is there any out of the box library which does that ?


I needed to implement simple test framework which would simulate JMS behaviour but using synchronous approach. Anyway I was able to find library which has Message Selector parser implemented - http://openjms.sourceforge.net/


Message selectors are not meant do allow this. Why you whould need this?

I'd recommend to create multiple consumers for it. E.g. from your example above I would create two consumers. One with this code:

//do sth

and the second for

//do sth else

The first would have the selector and the second the selector logically opposite.

If you really need to do filtering after you receive the message you can directly compare your headers and properties from the incoming message. You can even process the body while selectors cannot do that.

http://download.oracle.com/javaee/5/tutorial/doc/bnceh.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜