[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

switch on the fly from a remoted server on one computer to a remoted server on a another computer

Greg

10/22/2004 2:19:00 PM

My application is using .Net remoting. Our current application is using a
config file to setup the remoting as follows:

<system.runtime.remoting>
<application>
<channels>
<channel ref="http" port="0">
<clientProviders>
<formatter ref="binary" />
</clientProviders>
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
</channel>
</channels>
<client url="http://localhost:44/EventBroadcaster">
<wellknown type="VV.Services.General.IEventBroadcast,
VV.Services.LCEPGeneral"
url="http://alarmmp4:4/EventBroadcaster?wsdl" />
</client>
</application>
</system.runtime.remoting>


The problem we need to solve, is that we need to programmatically setup the
remoting, and then switch, on the fly, from a remoted server on one computer
to a remoted server on a another computer, and we can't seem to get this
working properly. I would welcome any suggestions, or examples on how to
implement this.

Thank you, -greg


4 Answers

Sam Santiago

10/22/2004 3:47:00 PM

0

Here's an example of configuring HTTP channels programmatically:

Client Side:

Dim myEventBroadcast as IEventBroadcast
Dim clientProv As BinaryClientFormatterSinkProvider
Dim serverProv As BinaryServerFormatterSinkProvider = New
BinaryServerFormatterSinkProvider
serverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
clientProv = New BinaryClientFormatterSinkProvider
Dim props As IDictionary = New Hashtable
props("port") = 0
Dim chan As HttpChannel = New HttpChannel(props, clientProv, serverProv)
ChannelServices.RegisterChannel(chan)
myEventBroadcaster =
DirectCast(Activator.GetObject(GetType(IEventBroadcast),
"http://localhost:44/EventBroadcast"), IEventBroadcast)

Server Side:

Dim clientProv As BinaryClientFormatterSinkProvider
Dim serverProv As BinaryServerFormatterSinkProvider = New
BinaryServerFormatterSinkProviderserverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
clientProv = New BinaryClientFormatterSinkProvider
Dim props As IDictionary = New Hashtable
props("port") = 44
Dim chan As HttpChannel = New HttpChannel(props, clientProv, serverProv)
ChannelServices.RegisterChannel(chan)

RemotingConfiguration.RegisterWellKnownServiceType(GetType(IEventBroadcast),
"EventBroadcast", WellKnownObjectMode.Singleton)

In order to dynamically switch you would have to modify the URL the client
uses to instantiate the remote objects:

myEventBroadcaster =
DirectCast(Activator.GetObject(GetType(IEventBroadcast),
"http://localhost:44/EventBroadcast"), IEventBroadcast)

and ensure the any previous instances variable are garbage collected or
reassigned to to the new server. Assuming you have configured the servers
the same - same port and same protocol, otherwise your have unregister the
channel and register a new one.

Thanks,

Sam


--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"hazz" <hazz@sonic.net> wrote in message
news:OZgSTIEuEHA.2956@TK2MSFTNGP12.phx.gbl...
> My application is using .Net remoting. Our current application is using a
> config file to setup the remoting as follows:
>
> <system.runtime.remoting>
> <application>
> <channels>
> <channel ref="http" port="0">
> <clientProviders>
> <formatter ref="binary" />
> </clientProviders>
> <serverProviders>
> <formatter ref="binary" typeFilterLevel="Full" />
> </serverProviders>
> </channel>
> </channels>
> <client url="http://localhost:44/EventBroadcaster">
> <wellknown type="VV.Services.General.IEventBroadcast,
> VV.Services.LCEPGeneral"
> url="http://alarmmp4:4/EventBroadcaster?wsdl" />
> </client>
> </application>
> </system.runtime.remoting>
>
>
> The problem we need to solve, is that we need to programmatically setup
the
> remoting, and then switch, on the fly, from a remoted server on one
computer
> to a remoted server on a another computer, and we can't seem to get this
> working properly. I would welcome any suggestions, or examples on how to
> implement this.
>
> Thank you, -greg
>
>


Ken Kolda

10/22/2004 3:50:00 PM

0

I would say ditch the config file and whenever you need to fetch your server
object just use the Activator.GetObject() method. That would allow you to
specify what server you want the object from each time you retrieve it, e.g.

// Fetch remote object from localhost
object remoteObj = Activator.GetObject(typeof(MyRemoteObject),
http://localhost:44/EventBroadcaster);

// Fetch a remote object from another server
object remoteObj2 = Activator.GetObject(typeof(MyRemoteObject),
http://anotherserver:44/EventBroadcaster);

Ken


"hazz" <hazz@sonic.net> wrote in message
news:OZgSTIEuEHA.2956@TK2MSFTNGP12.phx.gbl...
> My application is using .Net remoting. Our current application is using a
> config file to setup the remoting as follows:
>
> <system.runtime.remoting>
> <application>
> <channels>
> <channel ref="http" port="0">
> <clientProviders>
> <formatter ref="binary" />
> </clientProviders>
> <serverProviders>
> <formatter ref="binary" typeFilterLevel="Full" />
> </serverProviders>
> </channel>
> </channels>
> <client url="http://localhost:44/EventBroadcaster">
> <wellknown type="VV.Services.General.IEventBroadcast,
> VV.Services.LCEPGeneral"
> url="http://alarmmp4:4/EventBroadcaster?wsdl" />
> </client>
> </application>
> </system.runtime.remoting>
>
>
> The problem we need to solve, is that we need to programmatically setup
the
> remoting, and then switch, on the fly, from a remoted server on one
computer
> to a remoted server on a another computer, and we can't seem to get this
> working properly. I would welcome any suggestions, or examples on how to
> implement this.
>
> Thank you, -greg
>
>


Greg

10/22/2004 4:15:00 PM

0

Sam,
I am just a 'channel' here passing on the question from a colleague.
Her response: "Awesome ! I am forwarding to swami for his review."
I am studying your answer as well.
Appreciatively,
Greg

"Sam Santiago" <ssantiago@n0spam-SoftiTechture.com> wrote in message
news:eXPUY5EuEHA.1596@TK2MSFTNGP10.phx.gbl...
> Here's an example of configuring HTTP channels programmatically:
>
> Client Side:
>
> Dim myEventBroadcast as IEventBroadcast
> Dim clientProv As BinaryClientFormatterSinkProvider
> Dim serverProv As BinaryServerFormatterSinkProvider = New
> BinaryServerFormatterSinkProvider
> serverProv.TypeFilterLevel =
> System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
> clientProv = New BinaryClientFormatterSinkProvider
> Dim props As IDictionary = New Hashtable
> props("port") = 0
> Dim chan As HttpChannel = New HttpChannel(props, clientProv, serverProv)
> ChannelServices.RegisterChannel(chan)
> myEventBroadcaster =
> DirectCast(Activator.GetObject(GetType(IEventBroadcast),
> "http://localhost:44/EventBroadcast"), IEventBroadcast)
>
> Server Side:
>
> Dim clientProv As BinaryClientFormatterSinkProvider
> Dim serverProv As BinaryServerFormatterSinkProvider = New
> BinaryServerFormatterSinkProviderserverProv.TypeFilterLevel =
> System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
> clientProv = New BinaryClientFormatterSinkProvider
> Dim props As IDictionary = New Hashtable
> props("port") = 44
> Dim chan As HttpChannel = New HttpChannel(props, clientProv, serverProv)
> ChannelServices.RegisterChannel(chan)
>
>
RemotingConfiguration.RegisterWellKnownServiceType(GetType(IEventBroadcast),
> "EventBroadcast", WellKnownObjectMode.Singleton)
>
> In order to dynamically switch you would have to modify the URL the client
> uses to instantiate the remote objects:
>
> myEventBroadcaster =
> DirectCast(Activator.GetObject(GetType(IEventBroadcast),
> "http://localhost:44/EventBroadcast"), IEventBroadcast)
>
> and ensure the any previous instances variable are garbage collected or
> reassigned to to the new server. Assuming you have configured the servers
> the same - same port and same protocol, otherwise your have unregister the
> channel and register a new one.
>
> Thanks,
>
> Sam
>
>
> --
> _______________________________
> Sam Santiago
> ssantiago@n0spam-SoftiTechture.com
> http://www.SoftiTe...
> _______________________________
> "hazz" <hazz@sonic.net> wrote in message
> news:OZgSTIEuEHA.2956@TK2MSFTNGP12.phx.gbl...
> > My application is using .Net remoting. Our current application is using
a
> > config file to setup the remoting as follows:
> >
> > <system.runtime.remoting>
> > <application>
> > <channels>
> > <channel ref="http" port="0">
> > <clientProviders>
> > <formatter ref="binary" />
> > </clientProviders>
> > <serverProviders>
> > <formatter ref="binary" typeFilterLevel="Full" />
> > </serverProviders>
> > </channel>
> > </channels>
> > <client url="http://localhost:44/EventBroadcaster">
> > <wellknown type="VV.Services.General.IEventBroadcast,
> > VV.Services.LCEPGeneral"
> > url="http://alarmmp4:4/EventBroadcaster?wsdl" />
> > </client>
> > </application>
> > </system.runtime.remoting>
> >
> >
> > The problem we need to solve, is that we need to programmatically setup
> the
> > remoting, and then switch, on the fly, from a remoted server on one
> computer
> > to a remoted server on a another computer, and we can't seem to get this
> > working properly. I would welcome any suggestions, or examples on how
to
> > implement this.
> >
> > Thank you, -greg
> >
> >
>
>


Greg

10/22/2004 4:18:00 PM

0

Ken,
I am merely a middle tier component passing on the question from a colleague
and your response back to her.
Her response: "Awesome ! I am forwarding to swami for his review."
I am also studying your answer and Sams.
Thank you so much,
Greg

"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> wrote in message
news:%23csFj7EuEHA.2596@TK2MSFTNGP15.phx.gbl...
> I would say ditch the config file and whenever you need to fetch your
server
> object just use the Activator.GetObject() method. That would allow you to
> specify what server you want the object from each time you retrieve it,
e.g.
>
> // Fetch remote object from localhost
> object remoteObj = Activator.GetObject(typeof(MyRemoteObject),
> http://localhost:44/EventBroadcaster);
>
> // Fetch a remote object from another server
> object remoteObj2 = Activator.GetObject(typeof(MyRemoteObject),
> http://anotherserver:44/EventBroadcaster);
>
> Ken
>
>
> "hazz" <hazz@sonic.net> wrote in message
> news:OZgSTIEuEHA.2956@TK2MSFTNGP12.phx.gbl...
> > My application is using .Net remoting. Our current application is using
a
> > config file to setup the remoting as follows:
> >
> > <system.runtime.remoting>
> > <application>
> > <channels>
> > <channel ref="http" port="0">
> > <clientProviders>
> > <formatter ref="binary" />
> > </clientProviders>
> > <serverProviders>
> > <formatter ref="binary" typeFilterLevel="Full" />
> > </serverProviders>
> > </channel>
> > </channels>
> > <client url="http://localhost:44/EventBroadcaster">
> > <wellknown type="VV.Services.General.IEventBroadcast,
> > VV.Services.LCEPGeneral"
> > url="http://alarmmp4:4/EventBroadcaster?wsdl" />
> > </client>
> > </application>
> > </system.runtime.remoting>
> >
> >
> > The problem we need to solve, is that we need to programmatically setup
> the
> > remoting, and then switch, on the fly, from a remoted server on one
> computer
> > to a remoted server on a another computer, and we can't seem to get this
> > working properly. I would welcome any suggestions, or examples on how
to
> > implement this.
> >
> > Thank you, -greg
> >
> >
>
>