How to do a divert using an xpath filter?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to do a divert using an xpath filter?

Frank Michael
Hi, I'm using version 2.6.3 of Artemis and trying to set up a divert from one queue to another using an xpath filter. Unfortunately this doesn't work as my XML Test messages are not getting diverted but stay in the incoming queue.
My adresses in broker.xml look like this      <addresses>         <address name="DLQ">            <anycast>               <queue name="DLQ" />            </anycast>         </address>         <address name="ExpiryQueue">            <anycast>               <queue name="ExpiryQueue" />            </anycast>         </address>
         <address name="Incoming">            <anycast>               <queue name="Incoming" />            </anycast>         </address>        <address name="XMLMessages">
            <anycast>               <queue name="XMLMessages" />            </anycast>         </address>        </addresses>
My divert looks like this   <diverts>   <divert name="xmldivert">
 <address>Incoming</address> <forwarding-address>XMLMessages</forwarding-address>                     <filter string="XPATH '//ContractedTimeTableMsg/Message'"/> 
     <exclusive>true</exclusive>   </divert>         </diverts>
My XML message looks like this<ContractedTimeTableMsg> <Message type="123"> </Message></ContractedTimeTableMsg>

Is it possible to use an XPATH Filter like this in a divert? If not, is there another, correct way to do it?I'm using Java 8 and a standalone installation of Artemis. Xalan is on the classpath, I tried version 2.6 and version 2.7.If this is generally the correct way, how would you debug this?
Reply | Threaded
Open this post in threaded view
|

Re: How to do a divert using an xpath filter?

jbertram
This isn't implemented yet.  See here [1].

That said, it doesn't appear that it would be that hard to implement.


Justin

[1]
https://github.com/apache/activemq-artemis/blob/master/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java#L210

On Tue, Oct 16, 2018 at 6:32 PM Frank Michael <[hidden email]>
wrote:

> Hi, I'm using version 2.6.3 of Artemis and trying to set up a divert from
> one queue to another using an xpath filter. Unfortunately this doesn't work
> as my XML Test messages are not getting diverted but stay in the incoming
> queue.
> My adresses in broker.xml look like this      <addresses>         <address
> name="DLQ">            <anycast>               <queue name="DLQ" />
>     </anycast>         </address>         <address name="ExpiryQueue">
>       <anycast>               <queue name="ExpiryQueue" />
> </anycast>         </address>
>          <address name="Incoming">            <anycast>
>  <queue name="Incoming" />            </anycast>         </address>
> <address name="XMLMessages">
>             <anycast>               <queue name="XMLMessages" />
>   </anycast>         </address>        </addresses>
> My divert looks like this   <diverts>   <divert name="xmldivert">
>  <address>Incoming</address>
> <forwarding-address>XMLMessages</forwarding-address>
>                     <filter string="XPATH
> '//ContractedTimeTableMsg/Message'"/>
>      <exclusive>true</exclusive>   </divert>         </diverts>
> My XML message looks like this<ContractedTimeTableMsg> <Message
> type="123"> </Message></ContractedTimeTableMsg>
>
> Is it possible to use an XPATH Filter like this in a divert? If not, is
> there another, correct way to do it?I'm using Java 8 and a standalone
> installation of Artemis. Xalan is on the classpath, I tried version 2.6 and
> version 2.7.If this is generally the correct way, how would you debug this?
Reply | Threaded
Open this post in threaded view
|

Re: How to do a divert using an xpath filter?

Frank Michael
 Hi Justin,
thanks for that quick answer, you solved some serious headscratching.
Is this documented anywhere? I think I read all the documentation of diverts but this isn't mentioned and there also doesn't seem to be any logging/exception going on.
Would this be considered a bug or a feature request or...?
Also, do I read this correctly, in my filter expressions right now I can use all AMQ* properties as well as any other header(!) key/value pair? Everything else will be silently ignored?
Any recommendation on how we could achieve this kind of divert with filtering in Artemis?
Michael


    Am Mittwoch, 17. Oktober 2018, 03:27:17 MESZ hat Justin Bertram <[hidden email]> Folgendes geschrieben:  
 
 This isn't implemented yet.  See here [1].

That said, it doesn't appear that it would be that hard to implement.


Justin

[1]
https://github.com/apache/activemq-artemis/blob/master/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java#L210

On Tue, Oct 16, 2018 at 6:32 PM Frank Michael <[hidden email]>
wrote:

> Hi, I'm using version 2.6.3 of Artemis and trying to set up a divert from
> one queue to another using an xpath filter. Unfortunately this doesn't work
> as my XML Test messages are not getting diverted but stay in the incoming
> queue.
> My adresses in broker.xml look like this      <addresses>        <address
> name="DLQ">            <anycast>              <queue name="DLQ" />
>    </anycast>        </address>        <address name="ExpiryQueue">
>      <anycast>              <queue name="ExpiryQueue" />
> </anycast>        </address>
>          <address name="Incoming">            <anycast>
>  <queue name="Incoming" />            </anycast>        </address>
> <address name="XMLMessages">
>            <anycast>              <queue name="XMLMessages" />
>  </anycast>        </address>        </addresses>
> My divert looks like this  <diverts>  <divert name="xmldivert">
>  <address>Incoming</address>
> <forwarding-address>XMLMessages</forwarding-address>
>                    <filter string="XPATH
> '//ContractedTimeTableMsg/Message'"/>
>      <exclusive>true</exclusive>  </divert>        </diverts>
> My XML message looks like this<ContractedTimeTableMsg> <Message
> type="123"> </Message></ContractedTimeTableMsg>
>
> Is it possible to use an XPATH Filter like this in a divert? If not, is
> there another, correct way to do it?I'm using Java 8 and a standalone
> installation of Artemis. Xalan is on the classpath, I tried version 2.6 and
> version 2.7.If this is generally the correct way, how would you debug this?
 
Reply | Threaded
Open this post in threaded view
|

Re: How to do a divert using an xpath filter?

jbertram
XPath support is not documented anywhere that I know of - probably because
it was never implemented.  Implementing such support would be a feature
request.

At the moment, filters only work on the message headers/properties.

If you want to filter with XPath on the body of the message your only
option would be to provide an implementation of the method I noted
previously.  I said previously that it didn't appear difficult to
implement.  However, there is a key difficulty - decoding the message body
(which is just a byte array) into a string.  The client could have encoded
the string any number of different ways, but the broker doesn't know how
the client encoded the string so it can't reliable decode the string.
That's probably why this wasn't implemented in the first place.


Justin

On Wed, Oct 17, 2018 at 1:55 AM Frank Michael <[hidden email]>
wrote:

>  Hi Justin,
> thanks for that quick answer, you solved some serious headscratching.
> Is this documented anywhere? I think I read all the documentation of
> diverts but this isn't mentioned and there also doesn't seem to be any
> logging/exception going on.
> Would this be considered a bug or a feature request or...?
> Also, do I read this correctly, in my filter expressions right now I can
> use all AMQ* properties as well as any other header(!) key/value pair?
> Everything else will be silently ignored?
> Any recommendation on how we could achieve this kind of divert with
> filtering in Artemis?
> Michael
>
>
>     Am Mittwoch, 17. Oktober 2018, 03:27:17 MESZ hat Justin Bertram <
> [hidden email]> Folgendes geschrieben:
>
>  This isn't implemented yet.  See here [1].
>
> That said, it doesn't appear that it would be that hard to implement.
>
>
> Justin
>
> [1]
>
> https://github.com/apache/activemq-artemis/blob/master/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java#L210
>
> On Tue, Oct 16, 2018 at 6:32 PM Frank Michael <[hidden email]>
> wrote:
>
> > Hi, I'm using version 2.6.3 of Artemis and trying to set up a divert from
> > one queue to another using an xpath filter. Unfortunately this doesn't
> work
> > as my XML Test messages are not getting diverted but stay in the incoming
> > queue.
> > My adresses in broker.xml look like this      <addresses>        <address
> > name="DLQ">            <anycast>              <queue name="DLQ" />
> >    </anycast>        </address>        <address name="ExpiryQueue">
> >      <anycast>              <queue name="ExpiryQueue" />
> > </anycast>        </address>
> >          <address name="Incoming">            <anycast>
> >  <queue name="Incoming" />            </anycast>        </address>
> > <address name="XMLMessages">
> >            <anycast>              <queue name="XMLMessages" />
> >  </anycast>        </address>        </addresses>
> > My divert looks like this  <diverts>  <divert name="xmldivert">
> >  <address>Incoming</address>
> > <forwarding-address>XMLMessages</forwarding-address>
> >                    <filter string="XPATH
> > '//ContractedTimeTableMsg/Message'"/>
> >      <exclusive>true</exclusive>  </divert>        </diverts>
> > My XML message looks like this<ContractedTimeTableMsg> <Message
> > type="123"> </Message></ContractedTimeTableMsg>
> >
> > Is it possible to use an XPATH Filter like this in a divert? If not, is
> > there another, correct way to do it?I'm using Java 8 and a standalone
> > installation of Artemis. Xalan is on the classpath, I tried version 2.6
> and
> > version 2.7.If this is generally the correct way, how would you debug
> this?
>
Reply | Threaded
Open this post in threaded view
|

Re: How to do a divert using an xpath filter?

Frank Michael
 XPath support is not documented anywhere that I know of - probably because
it was never implemented.  Implementing such support would be a feature
request.---It is "documented" here: http://activemq.apache.org/selectors.htmland states: Apache ActiveMQ also supports XPath based selectors when working with messages containing XML bodies. To use an XPath selector use the following syntaxAs this is not really true it would probably help to remove this section and put some info logs into the method.
Thanks again for your quick feedback, I filed a feature request.  
Reply | Threaded
Open this post in threaded view
|

Re: How to do a divert using an xpath filter?

jbertram
The documentation you referenced [1] is for ActiveMQ 5.x, not ActiveMQ
Artemis.  While the two brokers do implement much of the same functionality
they are independent of each other so the documentation for one does not
apply to the other.  The original question was about ActiveMQ Artemis which
does not reference XPath functionality in its filter/selector documentation
as far as I can tell.

Out of curiosity, do you have any plans to implement this?


Justin

[1] http://activemq.apache.org/selectors.html

On Fri, Oct 19, 2018 at 6:31 AM Frank Michael <[hidden email]>
wrote:

>  XPath support is not documented anywhere that I know of - probably because
> it was never implemented.  Implementing such support would be a feature
> request.---It is "documented" here:
> http://activemq.apache.org/selectors.htmland states: Apache ActiveMQ also
> supports XPath based selectors when working with messages containing XML
> bodies. To use an XPath selector use the following syntaxAs this is not
> really true it would probably help to remove this section and put some info
> logs into the method.
> Thanks again for your quick feedback, I filed a feature request.
Reply | Threaded
Open this post in threaded view
|

Re: How to do a divert using an xpath filter?

Frank Michael
 True, we were under the wrong assumption that ActiveMQ in this case meant Artemis.
Right now we don't have any plans to implement this.
    Am Samstag, 20. Oktober 2018, 02:57:32 MESZ hat Justin Bertram <[hidden email]> Folgendes geschrieben:  
 
 The documentation you referenced [1] is for ActiveMQ 5.x, not ActiveMQ
Artemis.  While the two brokers do implement much of the same functionality
they are independent of each other so the documentation for one does not
apply to the other.  The original question was about ActiveMQ Artemis which
does not reference XPath functionality in its filter/selector documentation
as far as I can tell.

Out of curiosity, do you have any plans to implement this?


Justin

[1] http://activemq.apache.org/selectors.html

On Fri, Oct 19, 2018 at 6:31 AM Frank Michael <[hidden email]>
wrote:

>  XPath support is not documented anywhere that I know of - probably because
> it was never implemented.  Implementing such support would be a feature
> request.---It is "documented" here:
> http://activemq.apache.org/selectors.htmland states: Apache ActiveMQ also
> supports XPath based selectors when working with messages containing XML
> bodies. To use an XPath selector use the following syntaxAs this is not
> really true it would probably help to remove this section and put some info
> logs into the method.
> Thanks again for your quick feedback, I filed a feature request.