gautamaino / gwteventservice

Automatically exported from code.google.com/p/gwteventservice
Other
0 stars 0 forks source link

Filters doesn't work #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. I build a service that need to push messages to all clients
2. I have single domain and I need to use filters. Client need to specify and 
add(modify on runtime) filter himself.
3. I create a listener and add a filter:
----------------------------------------------
EventFilter filter = new MessageEventFilter(shortNumberTextBox.getText(), 
phoneTextBox.getText());
        remoteEventService = RemoteEventServiceFactory.getInstance().getRemoteEventService();
        remoteEventService.addListener(MessageEvent.SERVER_MESSAGE_DOMAIN, new RemoteEventListener() {
            public void apply(Event anEvent) {
                if(anEvent instanceof MessageEvent) {
                    addMessage((MessageEvent)anEvent);
                }
            }
        },filter);
---------------------------------------------
On the server I put events like this:
---------------------------------------------
EventExecutorService eventExecutorService = 
EventExecutorServiceFactory.getInstance().getEventExecutorService("1");
        eventExecutorService.addEvent(MessageEvent.SERVER_MESSAGE_DOMAIN, messageEvent);
---------------------------------------------
I use "1" because I can't understand why i need to provide clientId if 
method(by javadoc) must return singleton.

What is the expected output? What do you see instead?

I want server to filter messages for every client, but when I add a filter by 
above way no events go to client. What I do wrong?

What version of the product are you using? On what operating system?
Linux,Apache Tomcat 6.0, gwteventservice-1.1.1

Please provide any additional information below.
Sorry for my poor english - i'm from Russia and know english wery bad.

Original issue reported on code.google.com by vladimir...@gmail.com on 8 Jul 2010 at 6:13

GoogleCodeExporter commented 8 years ago
Hi,

the problem is the static number "1" which you are using as the client id. The 
client id should be the session id (HttpServletRequest#getSession()#getId()) 
because the listener was registered to the client / session id with 
RemoteEventService#addListener(...). As an alternative you could extend from 
RemoteEventServiceServlet because these methods doesn't require a client id as 
a parameter.

Your english is good. :-)

Regards

Original comment by sven.strohschein@googlemail.com on 8 Jul 2010 at 9:09

GoogleCodeExporter commented 8 years ago
Thank you very match for answer! But I don't have client id when push event and 
i think i do not need it, because I must broadcast messages to all clients. 
Messages(Events) come to servlet from another service(RMI in my place) and in 
this threads I don't have http session, that why I use static "1". I also try 
to extends from RemoteEventServiceServlet, but in this case events do not come 
to clients 99% this is my mistake :)(maybe wrong sevlet mapping). I see sources 
of RemoteEventServiceServlet - it use current session to receive 
EventExecutorService. In my place, I think, no difference which way to use - in 
both thread do not have session. At this time I use domains as filters :), I 
think this is hack(maybe domains do not destroyed even after no clients 
subscribed to it - this is potential memory leak), but it works fine for me.

Original comment by vladimir...@gmail.com on 9 Jul 2010 at 9:05

GoogleCodeExporter commented 8 years ago
Sorry, you are right! It is possible to add events to a domain without a client 
id. The client id is only necessary for user-specific events and to register 
EventFilters. But your scenario should be working because the EventFilter is 
registered from the client side (with the right client id). When the event is 
added to the domain on the server side, the EventFilters of all registered 
clients of this domain will be processed.

I have built a small test scenario with HelloGWTEventService (patch attached). 
The EventFilter filters every second event, so the server generated message 
events are delivered every 10 seconds instead of every 5 seconds. I have done 
everything like in your code snipped above. Could you please compare my changes 
with your code? Maybe something of your MessageEventFilter is wrong. Or could 
it be that the events are sent before the Listener and EventFilter is 
registered? Or are you changing the EventFilter at the server side?

The registration of EventFilters require the client id because EventFilters are 
domain and user-specific. But that shouldn't be a problem in your scenario. We 
are currently working on additional pure domain-specific EventFilters (required 
for multiple session support).

There isn't a memory leak when you are using domains but it's not the cleanest 
way. ;-) The domains get removed when the last client is removed from the 
domain. The clients are removed when the listener is removed or automatically 
when a timeout occurs.

Original comment by sven.strohschein@googlemail.com on 10 Jul 2010 at 9:27

Attachments: