Announcement Announcement Module
Collapse
No announcement yet.
Calling a service from a service breaking! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling a service from a service breaking!

    Hello,
    I currently have two server services that I am exposing through HttpInvoker, FooManager and BarManager and are accessed via Swing client. These work fine when independent, but now Foo.doSomethingFoo() needs to call BarManager.doSomethingBar() as part of it's logic.

    My problem is that when I execute Foo.doSomething() on my client, the dynamic proxy for Foo on my client is trying to load my BarManager *implementation* which, rightly so, the client app context knows nothing about. What is the best practice when a service implementation needs to access another service on the client? Which app context loader should I be using to do this?

    This is what my client app context looks like:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>
    <!-- Configure remote Foo Manager access-->
    <bean id="fooManager" class="org.springframework.remoting.httpinvoker.Ht tpInvokerProxyFactoryBean">
    <property name="serviceUrl">
    <value>http://localhost:8080/myapp/remoting/PersistenceService</value>
    </property>
    <property name="serviceInterface">
    <value>com.zilliant.bar.IFoo</value>
    </property>
    </bean>

    <!-- Configure remote Bar Manager access-->
    <bean id="barManager" class="org.springframework.remoting.httpinvoker.Ht tpInvokerProxyFactoryBean">
    <property name="serviceUrl">
    <value>http://localhost:8080/myapp/remoting/BarService</value>
    </property>
    <property name="serviceInterface">
    <value>com.zilliant.bar.IBar</value>
    </property>
    </bean>
    </beans>



    Any assistance is greatly appreciated.

    Edward

  • #2
    If FooManager and BarManager are both on the client, and your client calls FooManager.doSomethingFoo(), it will go to the server implementation of FooManagerImpl. Then server-side FooManagerImpl should have a DI reference to a server-side BarManager (probably BarManagerImpl) and call the method.

    Or do you mean the above, but the server-side FooManagerImpl needs to call the client-side BarManager (let's call it ClientSideBarManagerImpl)? If so you cannot do this over HTTP as it is a request-response protocol (the server cannot simply start a new unrequested conversation with a client over HTTP). You'll need to look into RMI if you need to allow the server to call a method on the client. Or make the client expose some remoting endpoints over HTTP which the server can call (essentially the client becomes a server as well). Just be careful, as these sort of approaches are generally incompatible with proxy servers, firewalls, NAT routers etc.

    There are other solutions to this commonly explored problem, like long-running HTTP connections (so the server can "response" as part of the client's "request"), RMI compatibility approaches and extensions with proxy servers and HTTP, and the client running a HTTP "message pickup" thread which fires every few seconds to answer such questions. Most of the time it's easiest to figure out a way of avoiding the callback entirely.

    Comment

    Working...
    X