Re: Automatic failover for two .NET remoting servers

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

artmanaged33_at_newsgroup.nospam
Date: 11/30/04


Date: Tue, 30 Nov 2004 14:57:41 +0100

Hi!

Thanks for your suggestions.

I made much progress with my goal and have it working now.
The server part is not modified at all.
I don't use the backward-channel to my application,
all I have is one object from which I call all the methods. This
object has no state.

I created a clientsink and a IClientChannelSinkProvider.
My Clientsink is a messagesink and sits above the formatter.
It simply modifies the __Uri-Property to switch over after it
sees a message that has an Exception in it.
This is working quite nice, but I want a nicer interface for
my ClientChannelSinkProvider.
At the moment the failover-urls (several servers) are a property
of the ClientChannelSinkProvider which passes it on.

But I want to have my own protocol (e.g. swap:// ) instead of
http://

I tried in

public class SwapMessageSinkProvider : IClientChannelSinkProvider
{
public IClientChannelSink
CreateSink(System.Runtime.Remoting.Channels.IChannelSender channel,
string url,object remoteChannelData)
{
  //here url is parsed and modified to be "http://..."
IClientChannelSink nextSink=next.CreateSink(channel,url,remoteChannelData);

to parse the url (string url) and get my information and pass on a
"http://xxx"-type-url downwards to the HttpChannel.

But it doen't work, I get an exception.

BTW: I don't use config-files for remoting-configuration, but the following
simple code instead:

IClientChannelSinkProvider formatter=new
BinaryClientFormatterSinkProvider();
SwapMessageSinkProvider swap=new SwapMessageSinkProvider();
swap.Next=formatter;
ChannelServices.RegisterChannel(new HttpClientChannel(dict,failover));

So I only use HttpClientChannel and the BinaryClientFormatterSinkProvider.
No HttpChannel, only HttpClientChannel. (I have seen samples like the
jabber-channel
which register their jabber://-protocol insinde the JabberChannel-Class, not
in
the JabberClientChannel-Class)

Why doesn't it work to modify the url that is passed downwards to the
HttpClientChannel?

If I try it I get an exception in the later

m_server=(IServer)
Activator.GetObject(typeof(IServer),"swap://xxx;yyy;zzz");

I think that I somehow must register my swap:// protocol somewhere??

Many thanks in advance for your answer!