PDA

View Full Version : Publishing two remoting services dependant to each other


rantsi
08-31-2007, 11:49 AM
Hi,

Has anyone stumbled upon similar to mine or am I not seeing something obvious missing :confused:

I have two different executables which both use SaoExporter to publish some services. At the same time both of these exes are using services published by the other service using SaoFactoryObjects referring to the service. When starting up any of these programs they throw an exception "Connection could not be made since target machine actively refused it". This seems to pop up from initialization of these SaoFactoryObjects.

So has the initialization of SoaFactoryObjects changed dramatically since 1.0.2 because with that version of Spring this functionality seems to work and allow the programs to start up?

Timo

Bruno Baia
08-31-2007, 02:23 PM
Hi,


Has anyone stumbled upon similar to mine or am I not seeing something obvious missing :confused:

I have two different executables which both use SaoExporter to publish some services. At the same time both of these exes are using services published by the other service using SaoFactoryObjects referring to the service. When starting up any of these programs they throw an exception "Connection could not be made since target machine actively refused it". This seems to pop up from initialization of these SaoFactoryObjects.
Are you using the same port for the 2 different services ?
Do you have some code/configuration to share ?


So has the initialization of SoaFactoryObjects changed dramatically since 1.0.2 because with that version of Spring this functionality seems to work and allow the programs to start up?
1.0 is only Spring.Core and Spring.Aop. Spring.Services is available since 1.1

- Bruno

rantsi
08-31-2007, 02:46 PM
Hi,

Checked the Spring.Services version which was used before, it was 2.1.1.0.

Configuration should be equal to this snippet.

<!-- Server side-->
<object id="baseRemotingService" abstract="true" type="Spring.Remoting.SaoExporter, Spring.Services">
<property name="Infinite" value="true" />
</object>

<object id="ArchiveManagerService" parent="baseRemotingService">
<!-- archiveManager is proxied instance -->
<property name="TargetName" value="archiveManager" />
<property name="ServiceName" value="IArchiveManager.rem"/>
</object>

<!-- Client side -->
<object id="archiveManagerRemoteImplReference" type="Spring.Remoting.SaoFactoryObject, Spring.Services">
<property name="ServiceInterface" value="Pims.BusinessLogicInterface.IArchiveManager, Pims.BusinessLogicInterface" />
<property name="ServiceUrl" value="${server.service.url}IArchiveManager.rem" />
</object>


And the remoting configuration is done prior to instantiation of the spring context. Yes, the services do bind to different ports.

I know, it seems weird. But it looks like on instantiation of the client side proxy seems to require connection to server instance while building up the context. Though I have to read through the whole codebase of the application, since the original code is not mine.

Timo

rantsi
09-07-2007, 09:48 AM
Hi,

I got finally some time to look the reason behind this problem. The SaoFactoryObjects are opening connections to the services when IApplicationContext.GetObjectsOfType() is called. Seems that in case of SaoFactoryObject setting the ServiceInterface property is not enough to stop the call to open remote connections.

Timo

Erich Eichinger
09-09-2007, 12:07 PM
Hi,

I think I have an idea about the root cause for this problem. Can u plz post a stacktrace of this error? I'm interested in where the call to "IApplicationContext.GetObjectsOfType()" comes from. Are you using autowiring or autoproxying in your configuration?

Please try the following SaoFactoryObject implementation and let us know if it works then:

public class MySaoFactoryObject : Spring.Remoting.SaoFactoryObject, IFactoryObject, IInitializingObject
{
private bool isInitialized = false;

void IInitializingObject.AfterPropertiesSet()
{
base.AfterPropertiesSet();
isInitialized = true;
}

Type IFactoryObject.ObjectType
{
get { return (isInitialized) ? base.ObjectType : null; }
}
}


(apologies for any typos - didn't compile the above code yet)

cheers,
Erich

rantsi
09-13-2007, 03:37 PM
Hi,

The "IApplicationContext.GetObjectsOfType()" was sort of a dirty hack done long ago while exploring the possibilities of Spring. The call for that was made from our code to get all registered "plugins" so to say. When I got to remove this hack an replace it with proper injections the SaoFactoryObjects are now performing like they should be (not connecting to the service before correct method calls).

Timo

Erich Eichinger
09-13-2007, 04:14 PM
Hi,

did you try the "MySaoFactoryObject" approach?

cheers,
Erich

Bruno Baia
09-13-2007, 05:30 PM
Hi,

rantsi,
As you noticed IListableObjectFactory.GetObjectsOfType will call SaoFactoryObject's IFactoryObject.GetObject() and that's why connections will be opened to the service.

Erich,
I think you are confusing with IListableObjectFactory.GetObjectNamesForType used by autoproxying and autowiring.

Bruno

Erich Eichinger
09-13-2007, 05:36 PM
Bruno,

u are right. Tx for pointing out the difference.

cheers,
Erich