Results 1 to 8 of 8

Thread: RMI recovery (using RmiProxyFactoryBean)

  1. #1
    Join Date
    Aug 2004
    Location
    Brno, Czech Republic
    Posts
    48

    Default RMI recovery (using RmiProxyFactoryBean)

    Hi all,

    I'm using RmiProxyFactoryBean for binding my RMI remote objects into my Spring's application context. It works fine, but when the remote server restarts (or I stop and start the remote server again) calling methods on the "remote bean" starts to produce ConnectException-s .

    The only way to get it work again is to restart my application (eg. creation of new Spring application context).

    I'm sure there must be a better way how to recover the connection ... ?

    Any help kindly welcome, regards,
    Karel

  2. #2
    Join Date
    Aug 2004
    Location
    Brno, Czech Republic
    Posts
    48

    Default My solution

    Code:
    <bean id="feisService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
      <property name="serviceUrl"><value>rmi&#58;//xyz&#58;1099/FeisService</value></property>
      <property name="serviceInterface"><value>com.xyz.feissync.FeisService</value></property>
    </bean>	
    
    <bean id="feisSynchronizer" class="com.xyz.feissync.FeisSynchronizerImpl">
      <property name="feisService"><ref local="feisService"/></property>
    </bean>
    
    
    public class FeisSynchronizerImpl implements FeisSynchronizer, ApplicationContextAware &#123;
      private ApplicationContext ac;
      private FeisService feisService;
    
      public void setApplicationContext&#40;ApplicationContext ac&#41; throws BeansException &#123;
        this.ac = ac;
      &#125;
    
      public void setFeisService&#40;FeisService feisService&#41; &#123;
        this.feisService = feisService;
      &#125;
    
      public void syncFeisContracts&#40;&#41; &#123;
        List feisContracts = null;
        int repeatCount = 0;
        while &#40;repeatCount <= 1&#41; &#123;
          repeatCount++;
          try &#123;
            feisContracts = feisService.findContractsModifiedSince&#40;lastUpdateDate&#41;;
          &#125; catch &#40;RemoteException ex&#41; &#123;
            log.warn&#40;ex&#41;;
            log.info&#40;"Trying to obtain new feisService from application context"&#41;;
            InitializingBean factory = &#40;InitializingBean&#41;ac.getBean&#40;"&feisService"&#41;;
            try &#123;
              factory.afterPropertiesSet&#40;&#41;; // rebind remote server
              feisService = &#40;FeisService&#41;ac.getBean&#40;"feisService"&#41;;
            &#125; catch &#40;Exception ex2&#41; &#123;
              log.warn&#40;ex2&#41;;
            &#125;
          &#125;
        &#125;
      &#125;
    &#125;

  3. #3
    Join Date
    Aug 2004
    Location
    Brno, Czech Republic
    Posts
    48

    Default

    In Spring 1.1 this is greatly simplified due to new boolean properties of RmiClientInterceptor:
    - lookupRmiProxyOnStartup
    - cacheRmiProxy
    - refreshRmiProxyOnConnectFailure

    Thanks to Juergen!

  4. #4
    Join Date
    Sep 2004
    Location
    CQ,China
    Posts
    3

    Default I cannot find these new properties in spring1.1 api

    kajism,i cannot find these new properties in spring1.1 api you referred.
    Can you show me the right place to find?
    Many thanks.

  5. #5
    Join Date
    Aug 2004
    Location
    Brno, Czech Republic
    Posts
    48

    Default

    Hi, it is still in CVS only, because it was added after 1.1 RC2. So you can wait for the final release or get the latest CVS version. HTH, Karel

  6. #6
    Join Date
    Sep 2004
    Location
    CQ,China
    Posts
    3

    Default Thanks,kajism

    Thanks,kajism :lol:

  7. #7
    Join Date
    Aug 2004
    Posts
    19

    Default

    what a great new feature!
    I can not wait no more!

  8. #8
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    This is available in 1.1 final now, as "lookupStubOnStartup" / "cacheStub" / "refreshStubOnConnectFailure". Give it a try!

    Juergen (using Rod's account)
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Similar Threads

  1. Replies: 3
    Last Post: Mar 20th, 2009, 04:01 PM
  2. recovery of flow state after exception
    By jocsch in forum Web Flow
    Replies: 13
    Last Post: May 2nd, 2005, 04:13 PM
  3. RmiProxyFactoryBean ClassNotFound
    By cmgharris in forum Remoting
    Replies: 4
    Last Post: Apr 6th, 2005, 01:49 AM
  4. Recovery from a lost database connection
    By wpoitras in forum Data
    Replies: 4
    Last Post: Feb 22nd, 2005, 04:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •