RMI / clustering / remote references

We are currently in the process of designing the architecture for an application. We are considering using RMI as a mechanism of communication. The architecture is as such
          / App Server 1 \   / External Server 1
Web     /                \ /
Server                     X
          \ App Server 2 /   \ External Server 2
   DatabaseWhere App Server 1 and App Server 2 are stateless servers that provide exactly the same functionality. In fact the idea is that you can add more App Servers to increase performance as you wish. To keep the servers stateless, any state information is stored on the Database.
App Server 1 and App Server 2 can talk to either External Server 1 or External Server 2 to access remote functions.
So both External Server 1 and External Server 2 can provide the same Objects but calls relating to the same data may have to go back to the same External Server. (I.E. these external Servers are statefull)
This has raised several problems.
1/ If App Server 1 and App Server 2 both register it's remote Objects with the same Registry, how does the registry deal with this. Does it maintain two references or just the latest? Would using JNDI as the registry service help? Would the registry round-robin these references?
2/ Is there are way of storing stubs in a database. I.e App Server 1 requests an External Server remote object, External Server 1 is used, App Server 1 Stores this remote object to allow any App Server to continue the process. App Server 2 picks up the Remote object from the Database and carries on talking to External Server 1 through it.
Originally I was hoping to just bypass the whole Registry section and create my own lookup process. However I cannot see how this can be done. I tried looking to see how Sun actually do the Remote Binding in the Java Foundation Classes but it all seems to be done in the underlying sun.rmi classes...
any ideas?
Cheers
Ben

I've just found a solution to my last question. From this I should be able to create my own registry app that is contacted initially through this mechanism, and then any required exposed objects are passed to it using .exportObject() and serialisation. My registry app can then pick up objects of the same type and allow a round robin mechanism, etc...
import java.rmi.*;
import java.rmi.server.*;
import sun.rmi.server.UnicastServerRef;
import sun.rmi.transport.LiveRef;
public class MyServerImpl extends RemoteServer implements SimpleRMIInterface
    public static int SERVER_PORT = 1234; // the client should know it
    public static int SERVER_ID = 666; // the client should also know it
    public SimpleRMIImpl(String name) throws RemoteException
        LiveRef liveref = new LiveRef(new ObjID(SERVER_ID), SERVER_PORT);
        UnicastServerRef unicastserverref = new UnicastServerRef(liveref);
        ref = unicastserverref;
        unicastserverref.exportObject(this, null);
        // No need to do Naming.rebind(name, this);
... Interface methods implementation skipped
}Client implementation:
import java.rmi.server.*;
import sun.rmi.transport.tcp.TCPEndpoint;
import sun.rmi.transport.LiveRef;
import sun.rmi.server.UnicastRef;
public class SimpleRMIClient
    public static void main(String[] argv)
        try
            TCPEndpoint tcpendpoint = new TCPEndpoint("servername",1234); // I use port=1234 here
            LiveRef liveref = new LiveRef(new ObjID(666),    tcpendpoint,false);
            MyServerInterface myServerObject = (MyServerInterface) new MyServerImpl_Stub((RemoteRef) (new UnicastRef(liveref)));
            // No need to do Naming.lookup(serverName + "/" +
objectName);
        catch(Exception e)
            e.printStackTrace();
            System.exit(0);
            System.out.println("RMI connection successful");
}nice...
Ben

Similar Messages

  • Rmi remote reference lookup very slow in web start application

    I have a little problem with the RMI communication in a web start test application.
    It is a very simple program in which the client calls a remote object that returns a String.
    Everything seems to be working fine when i'm running/debugging the client app in eclipse, but when i package my client project into a jar file and run it as a web start application (i'm providing the jnlp on a local webserver) the remote reference lookup takes about 15 seconds.
    basically, what my client does is this:
    Registry registry = LocateRegistry.getRegistry(address);
    ServerTransaction st= (ServerTransaction) registry.lookup(name);
    String result = st.test();
    The server code looks like this:
    String name = "ServerTransaction";
    ServerTransaction engine = new DefaultServerTransaction();
    ServerTransaction stub = (ServerTransaction) UnicastRemoteObject.exportObject(engine, 0);
    Registry registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
    registry.rebind(name, stub);
    The server runs as a normal stand alone java application on my local machine as well.
    And here the content of the jnlp file for the client application:
    <resources>
         <jar href="WSTest.jar"/>
         <jar href="WSTestServer.jar"/>
         <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
         <property name="serverAddress" value="127.0.0.1" />
    </resources>
    <security>
         <all-permissions/>
    </security>
    <application-desc main-class="test.WSTest"/>
    As i said, the whole thing works when run as a normal java application as well as with web start, with the difference that the remote reference lookup takes about 15 seconds with web start.
    Can anyone tell me how i could go about this?

    Meanwhile, i tried the same thing at home on my xp machine (i use vista at work), and even though my test at home basically does the same thing (invoking a simple remote method that just returns "hello world") it worked pretty fast, contary to the 15 second hang on vista.
    So i can't really say where the problem is...
    I also found these two rmi properties
    sun.rmi.transport.connectionTimeout (1.1.6 and later)
    The value of this property represents the period (in milliseconds) for which socket connections may reside in an "unused" state, before the Java RMI runtime will allow those connections to be freed (closed). The default value is 15000 milliseconds (15 seconds).
    and
    sun.rmi.transport.proxy.connectTimeout (1.1 and later)
    The value of this property represents the maximum length of time (in milliseconds) that the Java RMI runtime will wait for a connection attempt (createSocket) to complete, before attempting to contact the server using HTTP. This property is only used when the http.proxyHost property is set and the value of java.rmi.server.disableHttp is false. The default value is 15000 milliseconds (15 seconds).
    Hoping it would help (totally clueless) i tried to set these as system properties via System.setProperty(...) to a lower value (if that even works this was - please correct me if i am totally wrong here) but it didn't help.

  • Remote reference to an RMI server

    I was going through some of the posts here and somebody mentioned : -
    "The Registry is a client that
    holds a reference to your remote object. If the remote object
    terminates, the reference remains, (as it would with any other
    client). You must manually purge the reference, (possibly with
    an unbind()).
    This is contrary to what I thought "the remote reference to an RMI server not implementing activatable remains valid as long as the server itself remains running and no longer. Is it a misunderstanding on my part?

    hi Ayesha,
    You are right
    "the remote reference to an RMI server not implementing activatable remains valid as long as the server itself remains running and no longer".

  • Activatable Servers and Remote References [RMI]

    Hello everyone,
    I'm wondering if there's a way to know, on an activatable server, how many clients have an active reference to that and their id. I need to know exactly who did not renew his lease with the server, and once I know it I can remove that client from a list of logged-in client..
    example:
    client "user1" gets a remote reference of the activatable server, that adds "user1" to a logged-in-list I made (like a online userlist in a forum). suddenly user1 crashes without invoking "logout" method (and for the userlist he's still online!).
    Once the lease for user1 expires, the activatable servers decreases the remoteRef count.
    I'd like to associate the client username with the remote reference or the lease in some way, so once a client lease is not renewed I know for sure who I've to remove with the server from the online userlist..
    Hope you can understand my problem, thanks in advance
    Edited by: Guguz on 28-dic-2010 6.44

    Each time a client connects to the login server, I give him a new activatable server.A new server. Making it activatable is pointless: you're creating it dynamically per client. Only the login server needs to be activatable. It goes something like this, modulo typos:
    public interface Login extends Remote
      Session login(String username, char[] password) throws RemoteException;
    public class LoginImpl extends Activatable implements Login
    public interface Session extends Remote
      // your session API here
      void logout() throws RemoteException; // explicit logout
    public class Session extends UnicastRemoteObject implements Session, Unreferenced
      // ... implementation of your session API
      // Unreferenced.unreferenced()
      public void unreferenced()
        // Log the enforced logout via unreferenced()
        logout();
      // logout()
      public void logout()
        // Log the logout
        // call UnicastRemoteObject.unexportObject(this, true);
        // and do whatever else you have to do when a client logs out
    In the activatable unreferenced methodIn the Unreferenced.unreferenced() method
    then I can put the "logout user".And wherever else it should go.
    And this should prevent crashes right ?Wrong. It won't prevent crashes. It will detect them.

  • Remote references

    Hi all,
    We have our product (RMI Client) that has references to objects that belong to various RMI servers running in different systems. This seem to spawn many RMIRenewClean and RMI ConnectionExpiration threads for each end point and they seem to still hang around for a long time.
    Obviously, there must be still some references I am holding to, which I am not aware of. Is there a way to find out which reference objects these threads are waiting to be released? Is there some RMI properties I need to set so as to get these logged somewhere?
    Thanks in advance
    Anand

    The home stub does know which host/port it was connected to, and I
    believe by default will attempt to reconnect. As long as you restarted
    the server on the same host/port, it can reconnect.
    That being said, it's probably a good practice to redo the JNDI lookup.
    -- Rob
    Emma wrote:
    I am currently investigating a problem with the reconnection of a client to the weblogic server after a server crash.
    We have a stateful session bean which provides functionality for logon and session management of the client. When the client first performs a logon, a lookup to the JNDI is done to get a remote reference to this bean's home object. Then the create method on the home interface is called to create the bean instance. If the server crashes then the reconnection code is called. This currently only contains the call to the create method and doesn't peform any JNDI lookups. I was expecting all references to be lost when the server crashed and therefore thought that this reconnection wouldn't work but it does! (The weblogic instance is not clustered) Does anyone have an explanation as to why this might happen?

  • RMI Clustering in Weblogic 7.0

    Hi !
    I am trying to use RMI Clustering in Weblogic 7.0. I followed the samples in the
    documentation and it doesnt work for me. I could successfully bing my RMi Server
    object to the JNDI tree and could view it via the weblogic JNDI tree. Even the
    lookup is fine, but when I invoke a method on the remote object via the client,
    I get the following error. Clearly there is something wrong with the Dynamic stub
    downloaded from the JNDI tree.
    Any Clues please...
    Thanks
    Sanjay
    class examples.rmi.hello.HelloImpl_WLStub
    java.rmi.ConnectException: Couldn't connect to weblogic.rjvm.RJVMImpl@3a0ab1 -
    id: '6003776402499002017C:15.10.45.93R:12
    46860412257523095S:15.10.45.93:[7001,7001,7002,7002,7001,7002,-1]:examples:examplesServer'
    connect time: 'Fri Sep 06 08:
    42:01 IST 2002'
    at weblogic.rjvm.ConnectionManager.getOutputStream(ConnectionManager.java:1559)
    at weblogic.rjvm.RJVMImpl.getRequestStream(RJVMImpl.java:363)
    at weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:88)
    at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:116)
    at examples.rmi.hello.HelloImpl_WLStub.sayHello(Unknown Source)
    at examples.rmi.hello.HelloClient.main(HelloClient.java:42)

    Hi !
    I am trying to use RMI Clustering in Weblogic 7.0. I followed the samples in the
    documentation and it doesnt work for me. I could successfully bing my RMi Server
    object to the JNDI tree and could view it via the weblogic JNDI tree. Even the
    lookup is fine, but when I invoke a method on the remote object via the client,
    I get the following error. Clearly there is something wrong with the Dynamic stub
    downloaded from the JNDI tree.
    Any Clues please...
    Thanks
    Sanjay
    class examples.rmi.hello.HelloImpl_WLStub
    java.rmi.ConnectException: Couldn't connect to weblogic.rjvm.RJVMImpl@3a0ab1 -
    id: '6003776402499002017C:15.10.45.93R:12
    46860412257523095S:15.10.45.93:[7001,7001,7002,7002,7001,7002,-1]:examples:examplesServer'
    connect time: 'Fri Sep 06 08:
    42:01 IST 2002'
    at weblogic.rjvm.ConnectionManager.getOutputStream(ConnectionManager.java:1559)
    at weblogic.rjvm.RJVMImpl.getRequestStream(RJVMImpl.java:363)
    at weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:88)
    at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:116)
    at examples.rmi.hello.HelloImpl_WLStub.sayHello(Unknown Source)
    at examples.rmi.hello.HelloClient.main(HelloClient.java:42)

  • Binding RMI-IIOP Remote Object in RMI Registry through JNDI

    hi friends
    I am writing RMI-IIOP Remote Object, both server program, and client program
    are java programs. Through JNDI (with cosnaming name service), my program is working.
    But what i want is, I want to use JNDI (with rmi registry name service) for my RMI-IIOP Remote Object ( and not RMI -JRMP Remote Object). Both my server
    program and client programs are java(and not corba)
    I am not getting this, while starting server its showing some error
    Is it not possible to bind rmi-iiop remote object in rmi registry through jndi, why

    because you are supposed to use the COSNaming service with IIOP. Even if you could bind an IIOP remote object into an RMIRegistry the clients wouldn't be able to use it because the RMI Registry doesn't do the extra processing that the COSNaming service does with IIOP references.

  • Remote reference is getting garbase collected

    Hi,
    I'm using Weblogic 5.1, on Windows NT.
    I have RMI remote object on the server side, and my client is an applet.
    In the applet I use JNDI to get the reference of the server object, and
    use it. The problem is after sometime ( like 10 min or so) I get
    weblogic.rmi.NoSuchObjectException
    and at the WLServer console I see
    ' <DGCServer> tried to renew lease for 1 lost reference'.
    At the server side, I bind the object using JNDI.
    I want thsi reference to be available all the time in the applet.
    any help is appreciated.
    thanks,
    Abdul.

    thanks, I will try and let you know by tomorrow.
    I tried both methods, you suggested, but i didn't get any errors. I still
    have to test the client connections and see whether they are gc'd or not.
    i gave a idletime of 1000.
    - Sam Jacob
    Iconixx Corp.
    Wei Guan <[email protected]> wrote in message
    news:[email protected]...
    set
    weblogic.rmi.dgc.idlePeriodsUntilTimeout=xxx
    in your weblogic.properties file.
    If it didn't work (I haven't tested),
    use -Dweblogic.rmi.dgc.idlePeriodsUntilTimeout=xxx in your startup script.
    Give a try and let me know.
    Cheers - Wei
    Sam <[email protected]> wrote in message
    news:[email protected]...
    how do you set this property.I think i have the same issue.
    Sam Jacob
    Iconixx Corp.
    Wei Guan <[email protected]> wrote in message
    news:[email protected]...
    You can tune up this property:
    weblogic.rmi.dgc.idlePeriodsUntilTimeout
    The default is 2. WebLogic will dereference a remote object referece
    if
    that
    reference hasn't been referenced for a period of time. The timeout
    value
    is
    determined by this property and other properties. The default idle
    timeout
    is 360 secs when idlePeriodsUntilTimeout=2. Use this formula to figurethe
    timeout: 60 x (4 + idlePeriodsUntilTimeout).
    Use at your own risk. If you set up this value too high, there will be
    unused remote reference on WebLogic server for cleaning up, which inturn
    degrade WeLogic performance.
    My 2 cents.
    Cheers - Wei
    aroshan <@cisco.com> wrote in message
    news:[email protected]...
    Hi,
    I'm using Weblogic 5.1, on Windows NT.
    I have RMI remote object on the server side, and my client is anapplet.
    In the applet I use JNDI to get the reference of the server object,and
    use it. The problem is after sometime ( like 10 min or so) I get
    weblogic.rmi.NoSuchObjectException
    and at the WLServer console I see
    ' <DGCServer> tried to renew lease for 1 lost reference'.
    At the server side, I bind the object using JNDI.
    I want thsi reference to be available all the time in the applet.
    any help is appreciated.
    thanks,
    Abdul.

  • Clustered Remote Object Bound To JNDI

    Hello,
              I'd like to know if Weblogic 5.1 (service pack 10) supports
              clusterable remote objects.
              What I am trying to do is to implement a remote object that extends
              UnicastRemoteObject interface and bind it to JNDI. When the client
              needs the services, it will lookup that object in JNDI and call its
              methods remotely.
              What happens to my test implementation is that it all works well when
              I run Weblogic locally, but if it is run on the remote server, it
              gives me the exception to the extend that the stub for my remote
              object is not found (although it is in the classpath). I understand
              that this is because I should be using weblogic.rmic instead of
              regular rmic, is that right?
              Thanks,
              Eugene Kononov.
              

    Hello,
              I'd like to know if Weblogic 5.1 (service pack 10) supports
              clusterable remote objects.
              What I am trying to do is to implement a remote object that extends
              UnicastRemoteObject interface and bind it to JNDI. When the client
              needs the services, it will lookup that object in JNDI and call its
              methods remotely.
              What happens to my test implementation is that it all works well when
              I run Weblogic locally, but if it is run on the remote server, it
              gives me the exception to the extend that the stub for my remote
              object is not found (although it is in the classpath). I understand
              that this is because I should be using weblogic.rmic instead of
              regular rmic, is that right?
              Thanks,
              Eugene Kononov.
              

  • Behaviour when caching remote reference..

    In this application, whose crazy behavior I am trying to fix -
    there are 2 Message driven beans that process message out of certain queues(say, batch and realtime)
    There is a util class to which the MDB's onMessage() methods delegate. Util class in turn delegates all calls to a session bean. The session bean is accessed via a static member variable of remote reference, which is intialized during first call. Calls to session bean method can take around 2 min to complete. Given that, what will be the system behavior when there is a very huge volume of messages in One of the queues(say batch)? will each new message wait until the previous session bean call is over?
    What is a safe session bean pool size in a very high volume environment?
    TIA
    RC

    Each MDB will process its message, then go onto the next available one etc. Depending on the MDB pool size you should be able to process messages concurrently in different MDBs.
    The only thing to be careful of is that your transaction timeout is not set so low that the container thinks the MDB is blocked and rolls back the transaction.
    James
    http://logicblaze.com/
    Open Source SOA

  • RMI Clustering

    Hi All,
    We have developed a Spring RMI application and we developed business logic in spring POJO's. Using this RMI technology I exposed my business components to client. Here I have developed userinterface with swings.
    It is a client server application. Here I didn't use any EJB kind of technology because spring provides
    some of the services like security and Transaction Management.
    But I have some questions regarding RMI based implementation.
    1) How can I put my application in clusturing environment?.
    2) Is there any application server providing clustering for SpringRMI/RMI application?.
    3) Is application server necessary for implementing clustering for Spring RMI based application?.
    4) Whether this approach is correct or not?
    Suggest me the currect approach and Spring RMI clustering.
    Thanks in Advance
    Mohan Reddy. M

    If you want reliable cluster-wide state replication, there's only one
              option: http://www.tangosol.com/products-clustering.jsp
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              Clustering Weblogic? You're either using Coherence, or you should be!
              Download a Tangosol Coherence eval today at http://www.tangosol.com/
              "Stone Cold Steve Austin" <[email protected]> wrote in
              message news:3cce62c9$[email protected]..
              >
              > What v understood from Failover for RMI Objects (RMI Clustering) is
              weblogic load
              > balances the method calls across servers in the cluster & doesn't
              implement fail-over
              > / replication.If our understanding is wrong can anyone guide us for
              replicating RMI
              > Objects like Http Session State Replication.
              

  • RMI Remote reference is getting garbage collected

    Hi,
    I'm using Weblogic 5.1, on Windows NT.
    I have RMI remote object on the server side, and my client is an applet.
    In the applet I use JNDI to get the reference of the server object, and
    use it. The problem is after sometime ( like 10 min or so) I get
    weblogic.rmi.NoSuchObjectException
    and at the WLServer console I see
    ' <DGCServer> tried to renew lease for 1 lost reference'.
    At the server side, I bind the object using JNDI.
    I want thsi reference to be available all the time in the applet.
    any help is appreciated.
    thanks,
    Abdul.

    Refer to my post on misc. Do not cross-post.
    Cheers - Wei
    aroshan <@cisco.com> wrote in message news:[email protected]..
    Hi,
    I'm using Weblogic 5.1, on Windows NT.
    I have RMI remote object on the server side, and my client is an applet.
    In the applet I use JNDI to get the reference of the server object, and
    use it. The problem is after sometime ( like 10 min or so) I get
    weblogic.rmi.NoSuchObjectException
    and at the WLServer console I see
    ' <DGCServer> tried to renew lease for 1 lost reference'.
    At the server side, I bind the object using JNDI.
    I want thsi reference to be available all the time in the applet.
    any help is appreciated.
    thanks,
    Abdul.

  • Returning remote reference

    Hi everybody, I'm having quite some trouble with RMI, everytime I try to return a reference to a Remote object on my server I get the usual "unmarshalling return" error. Problem is that my Object I'm trying to return actually implements the Remote interface:
    public interface Bank extends Remote {
         public Account create_account (String name) throws BankException, RemoteException;
    };the Implementation looks like this:
    public class BankImpl implements Bank {
         public Account create_account (String name) throws BankException {
              Account k = new AccountImpl(name);
              return k;
    }Again the interface and Implementation:
    public interface Account extends Remote {
        public Account(String name);
    public class AccountImpl implements Account, Remote  {
         private String name = null;
         AccountImpl(String name){
              this.name = name;
    };I'm quite stuck here, is there something I'm missing??? I thought that function whose return type is some implementation of the Remote interface will automatically get passed by reference with an automatically generated stub.

    It seems to me that having to actually extend the UnicastRemoteObject is quite a limitation.You don't have to. I gave you that as the simplest solution. If you don't extend UnicastRemoteObject, you have to export the object yourself with UnicastRemoteObject.exportObject(). Use the overload where you specify a port number, even if it's only zero (= any).
    And somehow I'm unable to cast the generated Proxies to my Interfaces.
    Actually I can only let my extend the "Remote" interface in my interfaces and them implement my Account interface and extend "UnicastRemoteObject" in the implementations and still it won't work.What happens? You'll have to show us the code ... btw is there something missing back there?
    Still think I'm missing something...For sure. RMI works.

  • RMI Clustering/Load Balancing

    I want to be able to access a stateless application deployed in an IAS 10g cluster, with a remote client using RMI and have the RMI requests load balanced and failed over between the cluster. The application doesn't use EJBs.
    Can anybody tell me how the client RMI requests could be load balanced and failed over accross the cluster?

    This is the document you want :- http://download.oracle.com/docs/cd/E12825_01/epm.111/epm_high_avail/launch.html
    or pdf version - http://download.oracle.com/docs/cd/E12825_01/epm.111/epm_high_avail.pdf
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Advantages ofusing RMI for remoting

    I would like to know the advantages of using RMI.
    As for my knowledge RMI is synchronous, and tightly coupled. Still it is used to register/lookup/invoke services.

    http://java.sun.com/products/jdk/rmi/
    http://java.sun.com/javase/technologies/core/basic/rmi/whitepaper/index.jsp
    http://java.sun.com/developer/Quizzes/rmi/index.html
    Note that the expected answer to question 5 is not correct. Services must implement a Remote interface.

Maybe you are looking for

  • Why is displaying LR thumbnails so processor-intensive?

    I'm using 1.4.1 for windows. I appreciate everyone's time who helps me get to the bottom of this. Why does LR take 100% of my processor resources during folder browsing? What is going on that requires so much power? I'm not yet making any edits to th

  • Picture too large

    After the new programming interface loaded, my screen is now too large. Specifically, the picture is too wide. Any ideas? It was perfect and I didn't change anything.

  • HTTP-400 Too many arguments passed

    Hello There, I installed the fresh 10g and applied patchset 2 on it. I get following error: HTTP-400 Too many arguments passed upper limit is 2000 Please help

  • Why is my ipod not recognized in itunes and content appears to be lost

    I recently connected my ipod to charge, when itunes did not come up I found that it was open by another user on our pc. I went to close itunes from there session But it was frozen. I had to press control alt delete to end task. When it closed I opene

  • Mobility Service Engine 7.4.100.0 ova WEB Services problem

    Hello, We have sucessfully installed MSE-VA-7-4-100-0.ova file in our Lab, and after installation we can't open https session with MSE. When we type <https://mymseipaddress> we are getting these message: Error 404 - Not Found. No service matched or h