-
1. Re: user-defined filter class instead of just filter expression
jbertram Feb 19, 2014 5:50 PM (in response to ulf.schroeter)1 of 1 people found this helpfulFilters currently can only be implemented via expressions. Filter classes are not supported.
Can you elaborate on your use-case a bit more? What specifically are you trying to filter that can't be accomplished with an expression? I assume you want to filter based on the message content rather than the headers or properties. If so, you might be able to implement what you're looking for with remoting interceptors which can be quite powerful.
-
2. Re: user-defined filter class instead of just filter expression
ulf.schroeter Feb 20, 2014 3:07 PM (in response to jbertram)Justin, thanks for the quick reply ! Just as an example we would like to implement server-side geo-referenced message filtering for moving message consumers (e.g. vehicles, ships).
The central server handles very huge amounts of geo-referenced (e.g. via message properties longitude and latitude) messages 'covering' the whole world.
Each moving message consumer is only interested in messages within a specific radius R (lets say 10 km) around its current geographic location. The current location will be send by all moving message consumers to the server e.g. each minute and will be stored within some singleton service (e.g. location manager).
Each moving message consumer has its own specific message queue on the server. Based on the dynamic message consumer locations the server should then automatically filter all incomming world-wide messages on consumer-specific queue insert.
The consumer-specific message filtering requires dynamic calculation of the geographic distance between geo-reference of each message and current consumer location.
Therefore latest consumer latitude/longitude information has to be gathered dynamically from the above mentioned location manager on each filter invocation. The both message and consumer latitude/longitude coordinates have to be converted to cartesian coordinates, doing of some vector math for distance calculation and finally testing the distance against the configured consumer radius-of-interest. (so nothing which can be done easily with some filter expression, but can be coded straight-forward within a user-defiend filter class)
I hope this illustrates one use-case requiring more complex and flexible filtering, there are for sure endless others. User-defined filter classes would be a very elegant and powerful solution to this problem and should fit nicely into the already generalized HornetQ filter concept for queues, bridges and diverts.
-
3. Re: Re: user-defined filter class instead of just filter expression
jbertram Feb 19, 2014 9:51 PM (in response to ulf.schroeter)Thanks for the explanation. It makes sense, and I certainly think the feature request is viable. Please raise a JIRA at HornetQ - JBoss Issue Tracker and assign it to me. Unfortunately I can't provide an ETA for this feature as I currently have other pressing work on the code-base related to cloud use-cases. We always welcome contributions, though. Feel free to send a PR to https://github.com/hornetq/hornetq.
Aside from a dedicated feature for this functionality, I think you might be able to improvise what you want using remoting interceptors. For example, I think something like this would probably work:
private class MyInterceptor implements Interceptor { public boolean intercept(final Packet packet, final RemotingConnection connection) throws HornetQException { if (packet.getType() == PacketImpl.SESS_SEND) { SessionSendMessage p = (SessionSendMessage) packet; ServerMessage sm = (ServerMessage) p.getMessage(); String address = sm.getAddress().toString(); if (address.equals("red")) { // arbitrary logic } else if (address.equals("green")) { // more arbitrary logic } } return true; } }
If you want to "filter out" the message (i.e. prevent it from going to the queue) simply return false. Otherwise return true. Read more about remoting interceptors at Chapter 47. Intercepting Operations.
-
4. Re: user-defined filter class instead of just filter expression
ataylor Feb 20, 2014 4:15 AM (in response to jbertram)moved to correct forum
-
5. Re: user-defined filter class instead of just filter expression
ulf.schroeter Feb 20, 2014 3:00 PM (in response to jbertram)Ok, will add a feature request. Thank you very much for the excellent support !
-
6. Re: user-defined filter class instead of just filter expression
jbertram Feb 21, 2014 12:02 PM (in response to ulf.schroeter)I'm curious to know if you're going to try implementing what you need using remoting interceptors. It will probably be awhile before I can implement this feature.
-
7. Re: user-defined filter class instead of just filter expression
ulf.schroeter Feb 22, 2014 4:05 AM (in response to jbertram)Thought to follow your invitation for extending the HornetQ source on my own and providing a Git PR. Already downloaded the source and realized that some parts of HornetQ come from the old JBoss 3.x messaging code base where I was already engaged in JBoss open-source development (can remember that we implemented the initial version of the message counter feature 10 years ago...). At the moment I am still struggeling a little bit with Git handling (used to CVS/SVN) and HornetQ project setup in Eclipse, but hopefully I will get it up and runnig.
-
8. Re: user-defined filter class instead of just filter expression
ulf.schroeter Feb 22, 2014 1:50 PM (in response to ulf.schroeter)Is there somewhere a tutorial how to import HornetQ maven project to Eclipse Kepler ? Tried to import HornetQ root directory (as downloaded from forked user-specific HornetQ on GitHub) via "File->Import...->Existing Maven Project", but there are errors on import and imported projects finally show all kinds of compile errors within Eclipse package explorer...
-
9. Re: user-defined filter class instead of just filter expression
jbertram Feb 25, 2014 10:27 AM (in response to ulf.schroeter)There is no such tutorial. All of the core developers use IntelliJ IDEA. I haven't used Eclipse regularly in a few years now.
As far as Maven goes, everything builds just as it should so I would expect Eclipse would be able to import everything appropriately. I do fresh imports of HornetQ branches all the time using IntelliJ IDEA and everything works great.
-
10. Re: user-defined filter class instead of just filter expression
clebert.suconic Feb 26, 2014 10:12 AM (in response to ulf.schroeter)You usually have to build it first before importing the project.
-
11. Re: user-defined filter class instead of just filter expression
clebert.suconic Feb 26, 2014 10:14 AM (in response to ulf.schroeter)Right, you are the author of MessageCounter for instance!
Ulf Schroeter wrote:
Thought to follow your invitation for extending the HornetQ source on my own and providing a Git PR. Already downloaded the source and realized that some parts of HornetQ come from the old JBoss 3.x messaging code base where I was already engaged in JBoss open-source development (can remember that we implemented the initial version of the message counter feature 10 years ago...). At the moment I am still struggeling a little bit with Git handling (used to CVS/SVN) and HornetQ project setup in Eclipse, but hopefully I will get it up and runnig.