Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.4.2
    • Fix Version/s: 5.9.0
    • Component/s: Selector
    • Labels:
      None
    • Environment:

      n/a

    • Patch Info:
      Patch Available

      Description

      As described in the Nabble thread, "custom selector / filter for messages", I have implemented message call support in selectors, together with a few initial functions and the ability to register new functions without modifying the core.

      Attached is a patch that implements this feature.

      There are no unit tests currently implemented, but I can provide them in the near future if needed.

        Activity

        Gary Tully made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Gary Tully [ gtully ]
        Fix Version/s 5.9.0 [ 12323932 ]
        Resolution Fixed [ 1 ]
        Hide
        Gary Tully added a comment -

        patch applied with thanks in http://svn.apache.org/r1478973
        added some unit test to validate and demonstrate.

        From: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java?view=diff&r1=1478972&r2=1478973&pathrev=1478973

        it is possible to see some examples:

                assertSelector(message, "REGEX('1870414179', SessionserverId)", false);
                message.setLongProperty("SessionserverId", 1870414179);
                assertSelector(message, "REGEX('1870414179', SessionserverId)", true);
                assertSelector(message, "REGEX('[0-9]*', SessionserverId)", true);
                assertSelector(message, "REGEX('^[1-8]*$', SessionserverId)", false);
                assertSelector(message, "REGEX('^[1-8]*$', SessionserverId)", false);
        
                assertSelector(message, "INLIST(SPLIT('Tom,Dick,George',','), name)", false);
                assertSelector(message, "INLIST(SPLIT('Tom,James,George',','), name)", true);
        
                assertSelector(message, "INLIST(MAKELIST('Tom','Dick','George'), name)", false);
                assertSelector(message, "INLIST(MAKELIST('Tom','James','George'), name)", true);
        
                assertSelector(message, "REGEX('connection1111', REPLACE(JMSMessageID,':',''))", true);
        Show
        Gary Tully added a comment - patch applied with thanks in http://svn.apache.org/r1478973 added some unit test to validate and demonstrate. From: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java?view=diff&r1=1478972&r2=1478973&pathrev=1478973 it is possible to see some examples: assertSelector(message, "REGEX('1870414179', SessionserverId)" , false ); message.setLongProperty( "SessionserverId" , 1870414179); assertSelector(message, "REGEX('1870414179', SessionserverId)" , true ); assertSelector(message, "REGEX('[0-9]*', SessionserverId)" , true ); assertSelector(message, "REGEX('^[1-8]*$', SessionserverId)" , false ); assertSelector(message, "REGEX('^[1-8]*$', SessionserverId)" , false ); assertSelector(message, "INLIST(SPLIT('Tom,Dick,George',','), name)" , false ); assertSelector(message, "INLIST(SPLIT('Tom,James,George',','), name)" , true ); assertSelector(message, "INLIST(MAKELIST('Tom','Dick','George'), name)" , false ); assertSelector(message, "INLIST(MAKELIST('Tom','James','George'), name)" , true ); assertSelector(message, "REGEX('connection1111', REPLACE(JMSMessageID,':',''))" , true );
        Gary Tully committed 1478973 (14 files)
        Hide
        Gary Tully added a comment -

        the spec does not impose any restrictions, so extending to support functions is fine from that perspective. It is a sensible "push of the envelope"

        Show
        Gary Tully added a comment - the spec does not impose any restrictions, so extending to support functions is fine from that perspective. It is a sensible "push of the envelope"
        Hide
        Claus Ibsen added a comment -

        Just from a JMS spec point of view, is it allowed to add support for extensions such as function calls?
        Despite it could be a nice feature.

        Show
        Claus Ibsen added a comment - Just from a JMS spec point of view, is it allowed to add support for extensions such as function calls? Despite it could be a nice feature.
        Hide
        Gary Tully added a comment -

        we need some unit tests to validate this new feature. There is no point adding features without tests because there will be nothing to protect the feature into the future.
        Unit tests are a must have

        Show
        Gary Tully added a comment - we need some unit tests to validate this new feature. There is no point adding features without tests because there will be nothing to protect the feature into the future. Unit tests are a must have
        Arthur Naseef made changes -
        Field Original Value New Value
        Attachment selectorFunctions.patch [ 12466513 ]
        Hide
        Arthur Naseef added a comment -

        Patch that adds function call syntax to the selector grammar, function call expressions, and a few initial functions.

        Show
        Arthur Naseef added a comment - Patch that adds function call syntax to the selector grammar, function call expressions, and a few initial functions.
        Arthur Naseef created issue -

          People

          • Assignee:
            Gary Tully
            Reporter:
            Arthur Naseef
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development