Announcement Announcement Module
Collapse
No announcement yet.
Remoting and callbacks Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Remoting and callbacks

    I've searched in the documentation and on the forums without finding any reference to the subject.

    Is it possible to perform callbacks using Spring remoting facilities? By callback, I mean the ability to perform a remote call passing a reference to a local object, and allow the remote server to call back the client thru that reference.

    I've done it in the past using RMI and I'm wondering if it's possible (and easier) using Spring.

  • #2
    Your topic title is 'Remoting and JMS', but I don't see where JMS comes in, as yuo don't mention it in the message, and JMS is not a remote call anyways.

    If yuo're using Spring's RMI remoting support, then a callback should be no problem, as per normal RMI. Otherwise, for any of the HTTP variants for example, you'd have to manually also bind a listener on the client side, or something of that nature.

    Comment


    • #3
      My topic title was "Remoting and callbacks", and I chose the "Remoting and JMS" forum because the forum description says that this forum is to "Support question relating to remoting support in Spring, including Hessian/Burlap, RMI, and JAX-RPC, as well as JMS related classes".

      Ok, so far for splitting hairs in two ;-)
      When I did callbacks with RMI it was tricky at best, so I was wondering if Spring provided some more support to simplify this use case (on top of the direct RMI call simplification which is really nice, of course)... a code example would be very useful, for instance ;-)

      Comment


      • #4
        Spring remoting generally will just expose some arbitrary object via RMI, it will also of course make the registration of said object pretty easy and transparent to your application code. So once that object is in RMI sure you can register a callback with it. It's all plain jane RMI at that point. The RMI client proxy also makes the client lookup and hence callback registration pretty easy as well. I don't really see these as much more than convenience methods though. The RMI'ing of abitrary objects is cool though and lets face it the convenience method is cool enough to warrant its use.

        When you say callbacks were tedious I am guessing you primarily mean:

        1. Managing RMI artifacts, stubs and skels: Yeah Spring and dynamic proxies help there.
        2. Managing the RMI registry and RMI server: No Spring won't help here. I regard this as the biggest pain actually. So most app server vendors have internalized some RMI server and registry functionality that eases this. I'm using RMI in Weblogic, not Weblogic RMI mind you and even this convenience was enough for us to consider a callback vs. polling solution on my current project.
        3. Managing the communication layer: Nope Spring won't help here. You can implement Unreferancable or do your own custom pings if that d/n work in your JRE but you basically are responsible for keeping things robust and talking.
        4. Managing some application protocol: Maybe you need retry or for the thing to participate loosely in some transaction. Spring d/n provide retry support on these remotable interfaces yet. Obviously there is no state in them either so the entire approach has as yet been of little use to me beyond simplifying registration of server objects and rapid prototyping.
        5. Traversing firewalls and NAT: Spring won't help here, an RMI proxy might though.

        I think the biggest challenges with RMI are still with RMI in general. Well there are new twists of course since the days of Jini when I used it the most. For example getting RMI to play nicely across a cluster with non cluster aware RMI stubs. Hell even with clustered RMI objects in Weblogic failover doesn't work as you might think. The server you registered the callback with is a p.o.f. if that server fails. So the new challenges for me were to get RMI callback to play nicely in a clustered container environment with pre 1.3 Jre's.

        If you can provide more info. on your env. and what in particular you want to see I can provide some sample code. In general though it's just RMI obscured through the Spring smoke and mirrors which are the only type of smoke and mirrors I don't mind these days.

        Comment


        • #5
          I have the same problem than "aaime". I use Spring's RMI facilities in client and server sides and that works very fine. But now, I want my client "listens" remote service events (like "aaime" callbacks). I do this using simple RMI API (exporting the listener through UnicastRemoteObject and extending listener interface from java.rmi.Remote), but that way dirties my Java code with RMI API.

          I can't figure out how can I do that using Spring's RMI facilities.

          My client-side-context is:
          Code:
          <beans>
              <bean id="client" class="my.spring.sample.rmi.client.Client" init-method="init">
                  <property name="service"><ref bean="accountService"/></property>
                  <property name="serviceListener"><ref bean="serviceListener"/></property>
              </bean>
              <bean id="accountService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
                  <property name="serviceUrl"><value>rmi&#58;//localhost&#58;1099/AccountService</value></property>
                  <property name="serviceInterface"><value>my.spring.sample.rmi.server.AccountService</value></property>
              </bean>
          </beans>
          My server-side-context is:
          Code:
          <beans>
              <bean id="accountService" class="my.spring.sample.rmi.server.AccountServiceImpl"/>
              <bean id="accountServiceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
                  <property name="serviceName"><value>AccountService</value></property>
                  <property name="service"><ref bean="accountService"/></property>
                  <property name="serviceInterface"><value>my.spring.sample.rmi.server.AccountService</value></property>
                  <property name="registryPort"><value>1099</value></property>
              </bean>
          </beans>
          Anybody can help me?

          Thanks in advance and sorry for my english.

          Comment


          • #6
            not all of spring remoting support call back.

            there are five choice in sprint RMI:
            1. traditional RMI <------ ***
            2. spring RMI wrapper for arbitery objects
            3. caucho hession
            4. caucho burlap
            5. httpinvoker

            *** Only traditional RMI support callback, right?

            Comment


            • #7
              Callbacks in Spring RMI? only with registry

              I think it may be possible to use callbacks in Spring RMI, but with the following caveat: clients must bind their RMI objects to a local registry.

              This is because:
              RMIServiceExporter binds exported services to a registry.
              RMIProxyFactoryBean lookups the stub using Naming.lookup.

              Unfortunately, i need my client apps to be able to use callbacks without using a registry (just as i can with traditional RMI), and this is proving difficult in Spring.

              I'm experimenting with:
              1) extending RMIServiceExporter to prevent the registry binding step
              2) extending RMIProxyFactoryBean to subvert the stub lookup process, supplying a injected client stub instead.

              But, things aren't going well

              Anyone attempted something like this?

              Comment


              • #8
                Re: Remoting and callbacks

                Originally posted by aaime
                I've searched in the documentation and on the forums without finding any reference to the subject.

                Is it possible to perform callbacks using Spring remoting facilities? By callback, I mean the ability to perform a remote call passing a reference to a local object, and allow the remote server to call back the client thru that reference.

                I've done it in the past using RMI and I'm wondering if it's possible (and easier) using Spring.
                BTW Lingo (http://lingo.codehaus.org) the Spring Remoting provider for JMS - supports asynchronous callbacks if you want to a try a non-RMI based Spring Remoting provider.

                Comment


                • #9
                  Has anything changed since last post. I think it is supported now but I am not able to make it work. I am passing parameter that implements Remote but Spring is still complaining that object is not serializable. Doc says it will pass it as traditional RMI remote object if interface implements Remote.

                  Comment

                  Working...
                  X