fantiq commented on issue #15446:
URL: https://github.com/apache/dubbo/issues/15446#issuecomment-2961448468

   > > > > Set `protocol` parameters on annotations,like this:
   > > > > @DubboReference(check=false,
   > > > > protocol="dubbo",
   > > > > stub="org.apache.dubbo.samples.stub.DemoServiceStub",
   > > > > onconnect = "print",
   > > > > interfaceName = "org.apache.dubbo.samples.stub.DemoService")
   > > > > private DemoService demoService;
   > > > 
   > > > 
   > > > Thanks a lot it worked, but why? I have defined 
`dubbo.consumer.protocal: dubbo` in application.yml but it doesn't work.
   > > 
   > > 
   > > can u please provider a complete example?
   > 
   > Sorry I don’t have more examples, but let me try to explain. From what I 
understand, if the `protocol` field isn’t set in `@DubboReference` , Dubbo will 
use the value from the config file — like `dubbo.consumer.protocol` or 
`dubbo.protocol.name` . And that works fine in most cases when `stub.event` is 
not involved.(In this issue, when I use `onconnect` , it automatically sets 
`stub.event` to `true` .)
   > 
   > And that’s where my question comes in. Why is `stub.event` treated 
differently? When I use `onconnect` or `ondisconnect` , why do I have to 
explicitly set the `protocol` field in `@DubboReference` for it to work? It’s 
not really explained in the official docs, so I’m not sure if this is expected 
behavior or a bug.
   
   the correct configuration item is `dubbo.consumer.protocol: dubbo`. You can 
use it in the configuration file instead of setting it in the annotations.
   
   If you have set the `onconnect` or `ondisconnect` options,proxy clients need 
to perform service export to listen for local network events, the `export` 
process need the protocol value.
   
   can look at 
`org.apache.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper#getProxy(org.apache.dubbo.rpc.Invoker<T>,
 boolean)` and 
`org.apache.dubbo.remoting.exchange.support.ExchangeHandlerAdapter#invoke`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to