Archived

This forum has been archived. Please start a new discussion on GitHub.

Why message display twice when I use IceBox+Interceptor

I'm testing IceBox&Interceptor using Visual Studio 2010.
In my Interceptor's dispatch method,I wrote:
class OrderOperationInterceptor : Ice.DispatchInterceptor
{

public override Ice.DispatchStatus dispatch(Ice.Request request)
{
Console.Out.WriteLine("From OrderOperationInterceptor dispatch");
Ice.DispatchStatus status = _servant.ice_dispatch(request);
Console.Out.WriteLine(Thread.CurrentThread.ManagedThreadId.ToString());
return status;
}

public OrderOperationInterceptor(Ice.Object obj)
{
_servant = obj;
}
private Ice.Object _servant;
}
but, I call this method by client invoke.The result is display twice messages,and the result is execute only once.
Why?

Comments

  • bernard
    bernard Jupiter, FL
    If you mark an operation as "idempotent", a single client invocation can occasionally result in 2 dispatches; without idempotent, Ice guarantees at most one dispatch. See Terminology - Ice 3.5 - ZeroC for more details.

    With a dispatch interceptor, the dispatch interceptor itself is a servant, which happens to delegate to another servant (or several other servants depending on your dispatch interceptor).

    I'd suggest to turn on tracing to get a better understanding of what's happening: you could trace protocol messages (Ice.Trace.Protocol=1) and also retries (Ice.Trace.Retry=1).

    If you can't figure this out, please post a more complete example, with your client code, the servant code, and also the output you're seeing (including the trace messages).

    Best regards,
    Bernard
  • Thanks your replay.
    It is sure my mistake.
    I pass the ServantLocator a DispatchInterceptor as param,but In Servant ServantLocator constructor renew a DispatchInterceptor.So, There are two DispatchInterceptor nested.
    When a request pass to ServantLocator,the ServantLocator return the new DisaptchIntercepter,In the new DispatchInterceptor, the reqeust pass to the old DispatchInterceptor, In the old DispatchIntercptor the servant is the true business servant.so Console is called twice.but in the new DispatchInterceptor, the servant is a DispatchInterceptor also.the result is display only once of couse.