You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by artnaseef <Ar...@Ticketmaster.com> on 2010/12/16 06:53:29 UTC

custom selector / filter for messages

We have a need to filter messages based on criteria that is too complex for
Selectors.  Our messages are in a proprietary binary format, so filtering
with XPATH or XQUERY is not an option.

The filtering must work off a string message property which contains a
comma-separated list of values.  Subscribers will be filtered 

based on values, at least one of which must exist in the list.  To make it
more complicated, the values in the list may contain 

wildcards, and subscribers may be assigned multiple acceptable values.

For example:
    msg property "authKeys" : "AAA,AAB,AB?"
    client authorized for: "ABB,BAA"
    * ABB matches AB?

Looking through selectors, BrokerFilter's messagePull(), Subscription
(matches), and BooleanExpression has not yielded a working solution.  The
closest was a custom BooleanExpression, but that failed with a network of
brokers when the openwire transport attempted to marshal the custom object
that was added using setAdditionalPredicate() on the ConsumerInfo object;
the result was a cast exception since my custom object didn't implement
DataStructure.

It would be best to use a solution that propogates through a network of
brokers, like a selector, to reduce network traffic and avoid potential
problems with stuck messages on queues, but that may not be necessary.

At this point, I think the best approach is adding a custom
regular-expression syntax to selectors - perhaps using a function syntax. 
Such as:

   REGEX ( <regex-exp>, <candidate> )

For example:

   REGEX ( authKeys, "ABB,BAA" )

Would such an update be accepted into the build?  If not, any
recommendations would be appreciated.

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/custom-selector-filter-for-messages-tp3090334p3090334.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: custom selector / filter for messages

Posted by artnaseef <Ar...@Ticketmaster.com>.
Thank you.  I hope the feature is well accepted.

There are no unit tests currently available; I'll work on them as time
permits (I'm new to writing JUnit tests).

https://issues.apache.org/jira/browse/AMQ-3097
https://issues.apache.org/jira/browse/AMQ-3097 

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/custom-selector-filter-for-messages-tp3090334p3093290.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: custom selector / filter for messages

Posted by Stan Lewis <sl...@fusesource.com>.
You should create a Jira for this here -
http://issues.apache.org/activemq/browse/AMQ, attach the patch there.
I suspect the committers will also ask if you can provide some unit
tests as part of the patch, forgive me if I missed them in your patch.
 I think it's a great feature though!

On Fri, Dec 17, 2010 at 5:17 PM, artnaseef
<Ar...@ticketmaster.com> wrote:
>
> Here's the corrected patch.
>
> http://activemq.2283324.n4.nabble.com/file/n3093202/selectorFunctions.patch
> selectorFunctions.patch
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/custom-selector-filter-for-messages-tp3090334p3093202.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>



-- 
Stan Lewis
FuseSource
Email: slewis@fusesource.com
Web: http://fusesource.com
Twitter: gashcrumb

Re: custom selector / filter for messages

Posted by artnaseef <Ar...@Ticketmaster.com>.
Here's the corrected patch.

http://activemq.2283324.n4.nabble.com/file/n3093202/selectorFunctions.patch
selectorFunctions.patch 
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/custom-selector-filter-for-messages-tp3090334p3093202.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: custom selector / filter for messages

Posted by artnaseef <Ar...@Ticketmaster.com>.
Here is a patch that adds function-call syntax to selectors, and defines 5
builtin functions.  For example:

  REGEX('sales.*', group)

returns true if the group heading matches the regular expression 'sales.*'. 
Included is a method for custom functions to be added without changes to the
core.

http://activemq.2283324.n4.nabble.com/file/n3093168/selectorFunctions.patch
selectorFunctions.patch 

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/custom-selector-filter-for-messages-tp3090334p3093168.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.