Hi,
I'm trying to implement a way of "failing over" remoting to a different server if I encounter SocketExceptions, etc when Remoting.
Rather than trying to change every place I make a remote call, I have attempted to implement a ClientChannelSink, as follows:
Public Class FailoverClientChannelSink
Inherits BaseChannelSinkWithProperties
Implements IClientChannelSink
Implements IMessageSink
I can configure this to be "in front of" the BinaryClientFormatter, however in SyncProcessMessage
Public Function SyncProcessMessage(ByVal msg As System.Runtime.Remoting.Messaging.IMessage) As System.Runtime.Remoting.Messaging.IMessage Implements System.Runtime.Remoting.Messaging.IMessageSink.SyncProcessMessage
Dim retmsg As IMessage = Nothing
Dim MessageSend As Boolean = False
While Not MessageSend
Try
Debug.WriteLine("In Syncprocess for FailoverMessageSink")
retmsg = _nextMsgSink.SyncProcessMessage(msg)
MessageSend = True
Catch ex As Exception
If TypeOf ex Is System.Runtime.Remoting.RemotingException Or TypeOf ex Is System.Net.Sockets.SocketException Then
SwitchRemoting(msg)
SyncProcessMessage(msg)
Else
Throw
End If
End Try
End While
Return retmsg
End Function
_nextMsgSink throws a SocketException which I can't catch (it bubbles straight up to the calling code). Therefore I don't get a chance to change the msg.Properties("__Uri").
Any ideas what I'm doing wrong? I've tried ContextAttributes, RealProxies, IMessageSinks and ClientMessageSinks and don't seem to be able to catch and deal with the exception in the correct place to be able to reconfigure the remoting URI.
Thanks,
Richard.