Announcement Announcement Module
Collapse
No announcement yet.
Accessing remote services using dynamic hostnames Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accessing remote services using dynamic hostnames

    I'm in the process of converting my application to use Spring DI, and hopefully eventually other portions of Spring. Spring makes a lot of sense, and works great for many areas of our system (with a bit of tweaking) but there is one need that I'm not yet sure of the best solution.

    We have a very distributed system in a tree-like model. The root system has to talk to 500+ different systems all of which have identical (EJB) services, and each of those systems has to talk between 2 and 30 different systems, each of which has a different set of identical (RMI) services. Having static configuration for all these hosts is simply not practical. Especially, as the system can have new systems added at any time.

    Today, we use a ServiceFactory that takes (essentially) the hostname and service required to get a remote service for each of theses hosts. I'm writing a new ServiceFactory that is Spring-aware. I've had two people (including Keith Donald at the NFJS Atlanta conference) suggest two different solutions to this problem, but with virtually no Spring knowledge at the time, they went right over my head.

    So, what is the best way to get a remote service proxy for a dynamic host?

    Thanks
    David

  • #2
    No suggestions for this situation?

    Comment


    • #3
      You could consider using a JndiObjectTargetSource or a possible subclass. You would set this on your EJB or RMI proxy, and for each call to getTarget() you would do your dynamic host assignment. Possibly caching each JNDI object by hostname.

      Comment


      • #4
        Originally posted by wpoitras
        You could consider using a JndiObjectTargetSource or a possible subclass. You would set this on your EJB or RMI proxy, and for each call to getTarget() you would do your dynamic host assignment. Possibly caching each JNDI object by hostname.
        I'm not sure I truly understand, "set this on your proxy". To me, the proxy only has methods for business interface methods, and by the time I have a proxy object isn't it already "connected"?

        Comment


        • #5
          Sorry, I was mixing up some concepts.

          Basically you need to have your EJB proxy lookup the EJB each time, using some algorithm to choose the host. Underneath you'd probably want to create some sort of cache of all the various home interfaces, one for each server. I'd suggest creating a subclass of SimpleRemoteStatelessSessionProxyFactoryBean that managed this. Each item in the cache would probably contain a copy of the looked up home, and probably its own JndiTemplate with the parameters needed to relookup the home if the home is lost. Take a look at the source code for SimpleRemoteStatelessSessionProxyFactoryBean and its subclasses to see where to override.

          Comment

          Working...
          X