Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Notify Container

I am writing a notify listener operation.

GigaSpace gigaSpace = // either create the GigaSpace or get it by injection

SimpleNotifyEventListenerContainer notifyEventListenerContainer = new SimpleNotifyContainerConfigurer(gigaSpace) .template(new Data(false)) .eventListenerAnnotation(new Object() { @SpaceDataEvent public void eventHappened() { eventCalled.set(true); } }).notifyContainer();

Do I need a listener for this operation? Or while a write operation is done in the space, the method eventHappened() will get called? Please let me know how the notify container works. h4. Attachments

[event.zip|/upfiles/13759707579898273.zip]

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=3243]{quote}

asked 2009-09-18 06:23:18 -0500

abhilash428 gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Yes, your method will be called when the event occurs.

Eitan h4. Attachments

[event.zip|/upfiles/13759707578304192.zip]

answered 2009-09-18 07:15:23 -0500

eitany gravatar image
edit flag offensive delete link more

Comments

Hi,

event() is not getting called after GridEntry is written to space.

Code is attached. Please tell me is it the right way to register notify event and listen for events. Do I require a listener also?

Regards,

Abhilash h4. Attachments

[event.zip|/upfiles/13759707584125711.zip]

abhilash428 gravatar imageabhilash428 ( 2009-09-18 07:34:47 -0500 )edit

The following works for me (I'm using the fifoSupport @SpaceClass annotation property comes with 7.0.1 - you can use the fifo with previous versions):

The space class: {code} import com.gigaspaces.annotation.pojo.FifoSupport; import com.gigaspaces.annotation.pojo.SpaceClass; import com.gigaspaces.annotation.pojo.SpaceId; import com.gigaspaces.annotation.pojo.SpaceProperty; import com.gigaspaces.annotation.pojo.SpaceRouting;

@SpaceClass (fifoSupport=FifoSupport.ALL) public class MyMessage {

private String id;
private String destinationName;

public MyMessage() {
}

@SpaceId(autoGenerate = false)
@SpaceRouting
public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

@SpaceProperty(index = SpaceProperty.IndexType.BASIC)
public String getDestinationName() {
    return destinationName;
}

public void setDestinationName(String destinationName) {
    this.destinationName = destinationName;
}

}

{code}

The application class (I'm starting both the space and accessing it via remote proxy from the same process for the sake of the test only: {code} import org.openspaces.core.GigaSpace; import org.openspaces.core.GigaSpaceConfigurer; import org.openspaces.core.space.UrlSpaceConfigurer;

import org.openspaces.events.adapter.SpaceDataEvent; import org.openspaces.events.notify.SimpleNotifyContainerConfigurer; import org.openspaces.events.notify.SimpleNotifyEventListenerContainer;

public class NotifyConMain {

public static void main(String[] args) {

    GigaSpace gigaEmbed = new GigaSpaceConfigurer(new UrlSpaceConfigurer("/./nsefeedspace")).gigaSpace();
    GigaSpace gigaRemote= new GigaSpaceConfigurer(new UrlSpaceConfigurer("jini://*/*/nsefeedspace")).gigaSpace();

    SimpleNotifyEventListenerContainer notifyEventListenerContainer = new SimpleNotifyContainerConfigurer(
            gigaRemote).template(new MyMessage()).eventListenerAnnotation(
            new Object() {
                @SpaceDataEvent
                public void event(MyMessage event) {
                    System.out.println("GOT EVENT >>>>>>>>>>>>>>>>> - Object ID:" + event.getId());
                    try {
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).fifo(true).notifyWrite(true).notifyUpdate(true)
            .notifyContainer();

for (int i=0;i<10;i++)
{
    MyMessage o = new MyMessage();
    o.setId(i+"");
    o.setDestinationName("Des"+ i);
    gigaRemote.write(o);
}

} } {code}

shay hassidim gravatar imageshay hassidim ( 2009-09-18 12:56:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2009-09-18 06:23:18 -0500

Seen: 169 times

Last updated: Sep 18 '09