You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@river.apache.org by ab...@gmail.com on 2009/09/14 23:01:34 UTC

Javaspaces notify and sending event data to client

Hi,

I am developing a stock market platform. I am writing Stock entries to javaspace and generating events. The event is notified in EventListener. 

Now I want to get the entry written to the space for which the event is generated and send the entry data to Servlet response. For servlet response I am already passing the HttpResponse object to the EventListener class and is available in notify() method.

Questions are as follows:

1) How can i retrieve the written entry from remote event in notify() method of the listener?
2) How can i make sure that the next event will call notify after the previous event data is send to the Servlet response? I tried using flush but invain.
3) How can i filter remote events?

Any help will be appreciated. Thanks in advance.


Re: Javaspaces notify and sending event data to client

Posted by Dominic Cleal <do...@cdo2.com>.
On Monday 14 September 2009 22:01:34 abhilashk.cse@gmail.com wrote:
> I am developing a stock market platform. I am writing Stock entries to
> javaspace and generating events. The event is notified in EventListener.
>
> Now I want to get the entry written to the space for which the event is
> generated and send the entry data to Servlet response. For servlet response
> I am already passing the HttpResponse object to the EventListener class and
> is available in notify() method.
>
> Questions are as follows:
>
> 1) How can i retrieve the written entry from remote event in notify()
> method of the listener?

Could a blocking read or take may be a better solution here?  The notify() 
part of the specification isn't guaranteed and is usually carried out on a 
best-effort basis.  A particular implementation may offer the ability to 
change this, but you could be restricting your choices.

Also check the JavaSpace05 specification for the registerForAvailabilityEvent 
method.  IIRC, it allows you to register a listener that receives a copy of 
the entry that triggered the event.

> 3) How can i filter remote events?

This is dependent on the template you specify when setting up the 
registration.  You can change the scope of your registration by changing the 
template.

Cheers,

-- 
Dominic Cleal
CDO2
88 Union Street
London
SE1 0NW
Tel: +44 (0)845 456 4460
Fax: +44 (0)845 456 4461
www.cdo2.com  www.cdovar.net

RE: Javaspaces notify and sending event data to client

Posted by Guy Korland <Gu...@gigaspaces.com>.
Hi,
 
>1) How can I retrieve the written entry from remote event in notify() method of the listener?
The JavaSpaces API doesn't support such method (you need to call the read method to find the Entry).
We in GigaSpaces extended the EventListener  because we realized this is the common case. So, the GigaSpaces implementation also allows you to get the Entry as part of the RemoteEvent.
See: http://www.gigaspaces.com/wiki/display/XAP7/Session+Based+Messaging+API#SessionBasedMessagingAPI-ReceivetheEvent <http://www.gigaspaces.com/wiki/display/XAP7/Session+Based+Messaging+API#SessionBasedMessagingAPI-ReceivetheEvent> 
 
>2) How can I make sure that the next event will call notify after the previous event data is send to the Servlet response? I tried using flush but invain.
Again this it's not supported by the JavaSpaces API (you should implement such pattern).
Again in GigaSpaces found that to be a very common case and added a FIFO support providing exactly what you asked.
See: http://www.gigaspaces.com/wiki/display/XAP7/Session+Based+Messaging+API#SessionBasedMessagingAPI-FIFOBasedNotifications <http://www.gigaspaces.com/wiki/display/XAP7/Session+Based+Messaging+API#SessionBasedMessagingAPI-FIFOBasedNotifications> 
 
>3) How can I filter remote events?
Filtering the JavaSpaces is based on the template matching, a more complex filtering is not available and such should be implemented by the user.
Funny to say but again this pattern was implemented as part of the GigaSpaces extension to the JavaSpaces API, using INotifyDelegatorFilter API.
See: http://www.gigaspaces.com/wiki/display/XAP7/Session+Based+Messaging+API#SessionBasedMessagingAPI-FilteringEvents <http://www.gigaspaces.com/wiki/display/XAP7/Session+Based+Messaging+API#SessionBasedMessagingAPI-FilteringEvents> 
 
Guy Korland
R&D Team Leader
GigaSpaces

________________________________

From: abhilashk.cse@gmail.com [mailto:abhilashk.cse@gmail.com]
Sent: Tue 9/15/2009 12:01 AM
To: river-user@incubator.apache.org
Subject: Javaspaces notify and sending event data to client


Hi,

I am developing a stock market platform. I am writing Stock entries to javaspace and generating events. The event is notified in EventListener.

Now I want to get the entry written to the space for which the event is generated and send the entry data to Servlet response. For servlet response I am already passing the HttpResponse object to the EventListener class and is available in notify() method.

Questions are as follows:

1) How can i retrieve the written entry from remote event in notify() method of the listener?
2) How can i make sure that the next event will call notify after the previous event data is send to the Servlet response? I tried using flush but invain.
3) How can i filter remote events?

Any help will be appreciated. Thanks in advance.