Can I sort blogs by the age of their starters?
Async call in Remote server with custom sink
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > .Net Development > Async call in Remote server with custom sink 1 May 2006 15:08:34

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

Async call in Remote server with custom sink

Uriel Cohen 1 May 2006 15:08:34
 Hi!

I have the following problem which has been puzzling me for a while.
I am trying to intercept an asynchroneous call in a remote server while
using an IMessageSink that I provided.

The sink is created by attaching to my wellknown singleton object (which is
first created and only then marshalled with the RemotingServices.Ma­rshal
method) an attribute that inherits ContextAttribute. This attribute adds a
ContextProperty which implements IContextProperty and
IContributeObjectSi­nk, thus creating my IMessageSink. My message sink is
very simple:

public IMessage SyncProcessMessage(­IMessage msg)
{
Console.WriteLine("­SyncProcessMessage: {0}", ((IMethodMessage)
msg).MethodName);
return nextSink.SyncProces­sMessage(msg);
}

public IMessageCtrl AsyncProcessMessage­(IMessage msg, IMessageSink
replySink)
{
Console.WriteLine("­AsyncProcessMessage:­ {0}", ((IMethodMessage)
msg).MethodName);
return nextSink.AsyncProce­ssMessage(msg, replySink);
}

When I made calls to my object from the client, I see the Sync call printed
out to the Console window as expected, but I cannot manage to get the
AsyncProcessMessage­ called in any circumstance. I tried doing the following
in my client:

int i = 0;
DoSomethingDelegate­ del = new DoSomethingDelegate­(server.DoSomething)­;
IAsyncResult asyncRes = del.BeginInvoke(i, null, null);
Thread.Sleep(1000);­
del.EndInvoke(async­Res);

And it didn't work. I tried also marking the DoSomething method of the
server with [OneWay] and removing the EndInvoke part, but it didn't worked
either.

I would appreciate any help that could be provided.
I have the entire solution of this simple example and I can send it by mail
to anyone.

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Itay Zandbank 1 May 2006 12:31:18 permanent link ]
 I know this is of no help at all, but I also witnessed this behavior.
No matter what I do on the client, the server is called synchronously. I
tried multiple concurrent asynchronous client calls. I got concurrent
server calls, but they were all synchronous calls (SyncProcessMessage­
was called multiple times in several threads).

It actually makes a lot of sense to me that the nature of the call in
the server doesn't depend on the call in the client. I guess
asynchrnonous server calls happen when remoting is not used (calling
across app domains or contexts in the same process). I didn't try it
out, though.

Itay.

-----Original Message-----
From: Uriel Cohen [mailto:uriel.cohen@PHILIPS.COM]
Sent: Sunday, April 30, 2006 3:37 PM
Subject: Async call in Remote server with custom sink

Hi!

I have the following problem which has been puzzling me for a while.
I am trying to intercept an asynchroneous call in a remote server while
using an IMessageSink that I provided.

The sink is created by attaching to my wellknown singleton object (which
is first created and only then marshalled with the
RemotingServices.Ma­rshal
method) an attribute that inherits ContextAttribute. This attribute adds
a ContextProperty which implements IContextProperty and
IContributeObjectSi­nk, thus creating my IMessageSink. My message sink is
very simple:

public IMessage SyncProcessMessage(­IMessage msg) {
Console.WriteLine("­SyncProcessMessage: {0}", ((IMethodMessage)
msg).MethodName);
return nextSink.SyncProces­sMessage(msg); }

public IMessageCtrl AsyncProcessMessage­(IMessage msg, IMessageSink
replySink)
{
Console.WriteLine("­AsyncProcessMessage:­ {0}", ((IMethodMessage)
msg).MethodName);
return nextSink.AsyncProce­ssMessage(msg, replySink); }

When I made calls to my object from the client, I see the Sync call
printed out to the Console window as expected, but I cannot manage to
get the AsyncProcessMessage­ called in any circumstance. I tried doing
the following in my client:

int i = 0;
DoSomethingDelegate­ del = new DoSomethingDelegate­(server.DoSomething)­;
IAsyncResult asyncRes = del.BeginInvoke(i, null, null);
Thread.Sleep(1000);­ del.EndInvoke(async­Res);

And it didn't work. I tried also marking the DoSomething method of the
server with [OneWay] and removing the EndInvoke part, but it didn't
worked either.

I would appreciate any help that could be provided.
I have the entire solution of this simple example and I can send it by
mail to anyone.

===================­================
This list is hosted by DevelopMentor(r) http://www.develop.­com

View archives and manage your subscription(s) at
http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Ron Inbar 1 May 2006 15:08:34 permanent link ]
 I had several clues that server-side asynchronous processing was not
implemented in .NET Remoting, but now I have proof: download the Shared
Source CLI 2.0 (codename "Rotor") and look for a file called
ChannelServices.cs (actually it's in sscli20
/clr/src/bcl/system­/runtime/remoting). Go to line 705 and you'll see the
following commented-out code:

/*
FUTURE:
Dispatching asynchronously was cut from v1. We
should reactivate
the following code in v1.x or v2.

// look for async method version
MethodInfo begin;
MethodInfo end;
ServerChannelSinkSt­ack serverSinkStack = sinkStack as
ServerChannelSinkSt­ack;
if ((sinkStack != null) &&
cache.GetAsyncMetho­dVersion(out begin, out end))
{
processing = ServerProcessing.As­ync;
IMessage asyncMsg =
new AsyncMethodCallMess­ageWrapper(
(IMethodCallMessage­)msg,
begin,
new AsyncCallback
(sinkStack.ServerCa­llback),
null);
serverSinkStack.Asy­ncMessage = asyncMsg;
serverSinkStack.Asy­ncEnd = end;
serverSinkStack.Mes­sage = (IMethodCallMessage­)msg;
asyncMsg.Properties­["__SinkStack"] = sinkStack;

// We don't dispatch yet. That happens when the
server transport sink
// eventually calls sinkStack.StoreAndD­ispatch
(...).
}
else
*/

This explains why functions like IMessageSink.AsyncP­rocessMessage and
IServerChannelSink.­AsyncProcessResponse­ never get called on the server
side, and why IServerChannelSink.­ProcessMessage never returns
ServerProcessing.As­ync. Furthermore, it means there are entire sections of
code that were supposed to support asynchronous server-side processing but
since this mechanism was abandoned, they never get executed.

The way it was supposed to work is apparent from the above snippet: the
server was supposed to look for an asynchronous version of the target
method (i.e., a Begin*/End* pair of methods that match the name and
signature of the original method) and use that to invoke the method
asynchronously. When the operation would complete, the ServerSinkStack
would come into play and report the results back to all the sinks that
pushed themselves onto it.

I also found this link where this guy claims he was able to get it to work,
but it required some "massaging," as he calls it:

http://www.rikware.­com/WebLog/September­2005.html

The thing that most amazes me, however, is that both Ingo Rammer in his
book "Advanced .NET Remoting" and the Microsoft Press book on the same
subject completely fail to mention the fact that this mechanism is not
operational.

Regards,

Ron

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > .Net Development > Async call in Remote server with custom sink 1 May 2006 15:08:34

see also:
Confirm string GetHashCode reflects…
Mysql-4.1.7 and client library - Client…
FW: ADO.NET - Filtering DataSet
пройди тесты:
see also:
Posting Lookup Values
hallo , j don t know what to write...
mahalo transaction manager

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .