tree: 4e1ec77779a195a1733b1380c15c349989beda8f [path history] [tgz]
  1. go-client/
  2. go-server/
  3. java-client/
  4. java-server/

Generic Reference Example

1. Introduction

Generic invocation is mainly used when the client does not have API interface or model class, all POJOs in parameters and return values are represented by Map. Commonly used for framework integration such as: implementing a common service testing framework, all service implementations can be invoked via GenericService.

2. Code

var ( 
    //appName is the unique identification of RPCService 
    appName         = "UserConsumer"
    referenceConfig = config.ReferenceConfig{
        InterfaceName: "org.apache.dubbo.UserProvider",
        Cluster:       "failover",
        Registry:      "demoZk",
        Protocol:      dubbo.DUBBO,
        Generic:       true,

func init() {
    time.Sleep(3 * time.Second)

func main() {
    resp, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke(
    		//method name
    		//parameter type
    		//parameter array