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

Ask Your Question
0

Session Based Messaging API question -- what would block notifications?

Hi,

I have an application that uses the Session Based Messaging API to receive notifications of when certain types of Entries are written to a space. This application works fine on Windows, but when I try it out under Mac OS-X and Linux, it does not receive any of these write notifications, although all other space operations (read/write/take) all work fine. Just no notifications.

Is there anything that might block these notifications from arriving? Are there network topology issues that I should be aware of (ie...I must be on a LAN with the space server vs a WAN or VPN, etc) ???

thanks,

-dave

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

asked 2009-03-03 13:39:51 -0500

jazzbutcher gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

Try to set the client side JVM to have the java.rmi.server.hostname property set. This should have the IP of the machine.

Shay

answered 2009-03-03 13:43:06 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Comments

Shay,

I set the the java.rmi.server.hostname property on the client application with the IP address of the client machine. I did not see any change. No notifications are being caught, although they get caught fine on a Windows machine.

Any ideas?

thanks,

-dave

jazzbutcher gravatar imagejazzbutcher ( 2009-03-05 09:40:00 -0500 )edit

Are you sure the space machine can ping the IP you set for the client? Are you sure all ports are open between the space machine and the client box? Do you have the windows and the other machines on the same network? Do you see any errors at the space log file? Shay

shay hassidim gravatar imageshay hassidim ( 2009-03-05 09:46:00 -0500 )edit

Hmmm.... looks like it could be a port issue... what port or port range needs to be free?

thanks,

-dave

jazzbutcher gravatar imagejazzbutcher ( 2009-03-05 10:11:09 -0500 )edit

GigaSpaces communication protocol (aka LRMI) picks a random free ports for the client-space activities. To control the ports you should set the com.gs.transport_protocol.lrmi.bind-port property (client and space JVM): See example: -Dcom.gs.transport_protocol.lrmi.bind-port", "1700-1800,2000-2100,2500"

Shay

shay hassidim gravatar imageshay hassidim ( 2009-03-06 09:19:53 -0500 )edit

Thank you very much for the info, Shay.

-dave

jazzbutcher gravatar imagejazzbutcher ( 2009-03-09 09:41:51 -0500 )edit
0

I got almost the same issue. Notify(...) did not get invoked. Does your code work finally after Shay's instruction?

answered 2013-11-28 21:23:09 -0500

Benson gravatar image
edit flag offensive delete link more
0

Here is an example using the Session Messaging API:

package com.test;

import java.rmi.RemoteException;

import org.openspaces.core.GigaSpace;
import org.openspaces.core.GigaSpaceConfigurer;
import org.openspaces.core.space.UrlSpaceConfigurer;

import net.jini.core.entry.UnusableEntryException;
import net.jini.core.event.EventRegistration;
import net.jini.core.event.RemoteEvent;
import net.jini.core.event.RemoteEventListener;
import net.jini.core.event.UnknownEventException;
import net.jini.core.lease.Lease;

import com.gigaspaces.events.DataEventSession;
import com.gigaspaces.events.EventSessionConfig;
import com.gigaspaces.events.EventSessionFactory;
import com.gigaspaces.events.NotifyActionType;
import com.j_spaces.core.client.EntryArrivedRemoteEvent;

public class SessionBasedMessagingExampleMain implements RemoteEventListener{

    public static void main(String[] args) throws Exception{

        GigaSpace _gigaspace = new GigaSpaceConfigurer(new UrlSpaceConfigurer("/./space")).gigaSpace();

        GigaSpace gigaspace = new GigaSpaceConfigurer(new UrlSpaceConfigurer("jini://*/*/space")).gigaSpace();

        new SessionBasedMessagingExampleMain().register(gigaspace);

        Thread.sleep(2000);
        for (long i=0;i<10;i++)
        {
            MyData d = new MyData();
            d.setId(i);
            d.setData("AAAAA" + i);
            System.out.println("Writing Object " + i);
            gigaspace.write(d);
        }
    }
    void register(GigaSpace gigaspace) throws Exception
    {
        EventSessionFactory factory = EventSessionFactory.getFactory(gigaspace.getSpace());
        EventSessionConfig config = new EventSessionConfig();
        config.setFifo(true);
        DataEventSession session = factory.newDataEventSession(config);
        EventRegistration registration = session.addListener(new MyData(),this,Lease.FOREVER,null,null,NotifyActionType.NOTIFY_WRITE);

    }
    @Override
    public void notify(RemoteEvent event) throws UnknownEventException,RemoteException {

        EntryArrivedRemoteEvent arrivedRemoteEvent =(EntryArrivedRemoteEvent) event;
        MyData msg=null;
        try {
            msg = (MyData) arrivedRemoteEvent.getObject();
        } catch (UnusableEntryException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("Got event:" + event);
        System.out.println("Event Triggered Object:" + msg);

    }

}

The Space Class:

package com.test;

import com.gigaspaces.annotation.pojo.FifoSupport;
import com.gigaspaces.annotation.pojo.SpaceClass;
import com.gigaspaces.annotation.pojo.SpaceId;

@SpaceClass (fifoSupport=FifoSupport.ALL)
public class MyData {
    Long id;
    String data;

    public MyData (){}

    @SpaceId(autoGenerate=false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getData() {
        return data;
    }
    public void setData(String data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "MyData [id=" + id + ", data=" + data + "]";
    }
}

Expected output:

Writing Object 0
Writing Object 1
Writing Object 2
Writing Object 3
Writing Object 4
Writing Object 5
Writing Object 6
Writing Object 7
Writing Object 8
Writing Object 9
Got event: [Source space: space]
 [ EventId: 1]
 [ SeqId: 0]
 [ NotifyType: 1]
 [ SpaceUUID: b0fc8211-9cdc-4da2-b7e1-9db6b939e18b]
Event Triggered Object:MyData [id=0, data=AAAAA0]
Got event: [Source space: space]
 [ EventId: 1]
 [ SeqId: 1]
 [ NotifyType: 1]
 [ SpaceUUID: b0fc8211-9cdc-4da2-b7e1-9db6b939e18b]
Event Triggered Object:MyData [id=1, data=AAAAA1]
Got event: [Source space: space]
 [ EventId: 1]
 [ SeqId: 2]
 [ NotifyType: 1]
 [ SpaceUUID: b0fc8211-9cdc-4da2-b7e1-9db6b939e18b]
Event Triggered Object:MyData [id=2, data=AAAAA2]
Got event: [Source space: space]
 [ EventId: 1]
 [ SeqId: 3]
 [ NotifyType: 1]
 [ SpaceUUID: b0fc8211-9cdc-4da2-b7e1-9db6b939e18b]
Event Triggered Object:MyData [id=3, data=AAAAA3]
Got event: [Source space: space]
 [ EventId: 1]
 [ SeqId: 4]
 [ NotifyType: 1]
 [ SpaceUUID: b0fc8211-9cdc-4da2-b7e1-9db6b939e18b]
Event Triggered Object:MyData [id=4, data=AAAAA4]
Got event: [Source space: space]
 [ EventId: 1]
 [ SeqId: 5]
 [ NotifyType: 1]
 [ SpaceUUID: b0fc8211-9cdc-4da2-b7e1-9db6b939e18b]
Event Triggered Object:MyData [id=5, data=AAAAA5]
Got event: [Source space: space]
 [ EventId: 1]
 [ SeqId: 6]
 [ NotifyType: 1]
 [ SpaceUUID: b0fc8211-9cdc-4da2-b7e1-9db6b939e18b]
Event Triggered Object:MyData [id=6, data=AAAAA6]
Got event: [Source space: space]
 [ EventId: 1]
 [ SeqId: 7]
 [ NotifyType: 1]
 [ SpaceUUID: b0fc8211-9cdc-4da2-b7e1-9db6b939e18b]
Event Triggered Object:MyData [id=7, data=AAAAA7]
Got event: [Source space: space]
 [ EventId: 1]
 [ SeqId: 8]
 [ NotifyType: 1]
 [ SpaceUUID: b0fc8211-9cdc-4da2-b7e1-9db6b939e18b]
Event Triggered Object:MyData [id=8, data=AAAAA8]
Got event: [Source space: space]
 [ EventId: 1]
 [ SeqId: 9]
 [ NotifyType: 1]
 [ SpaceUUID: b0fc8211-9cdc-4da2-b7e1-9db6b939e18b]
Event Triggered Object:MyData [id=9, data=AAAAA9]

answered 2013-11-30 22:15:46 -0500

shay hassidim gravatar image
edit flag offensive delete link more

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-03-03 13:39:51 -0500

Seen: 110 times

Last updated: Nov 30 '13