springboot + HttpInvoke implement RPC calls

Springboot2 + began when hession4 implement RPC service, the first service discovery can be called successful, but the second has been reported '<' is an unknown code. The first service can still call. Online reference method, the client and server versions hession consistent view the local version is the same, replaced by other versions have no effect. Overloaded methods set to true, to no avail. If there are other small partners have had a solution, correct me hope. After the switch with the spring comes HTTPInvoke. Now recorded as follows:

 

1, the service end of the service exposed

@Configuration

public class HttpInvokeServiceConfig {

 

@Bean("/xxx")

public HttpInvokerServiceExporter rpcService(xxxService xxxService) {

HttpInvokerServiceExporter httpInvokerServiceExporter = new HttpInvokerServiceExporter();

httpInvokerServiceExporter.setService(xxxService);

httpInvokerServiceExporter.setServiceInterface(xxxService.class);

return httpInvokerServiceExporter;

}

}

 

2, the client interface to the Agent to perform remote method

 

@Configuration

public class ClientRpcConfig {

 

@Bean

public HttpInvokerProxyFactoryBean rpcService() {

HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean();

httpInvokerProxyFactoryBean.setServiceUrl(server_url);

httpInvokerProxyFactoryBean.setServiceInterface(xxxService.class);

return httpInvokerProxyFactoryBean;

}

}

 

important point

 

1), consistent with the client server interface name, the same method parameters

2) If the parameter is an interface object, then the object parameters required to implement the serialization

3), the interface parameter is the object, then the server should be consistent with the client object name, they have the same package path. Otherwise you will not find the class newspaper

 

 

3, the interface will be injected where needed remote method invocation interface defined can be realized

Guess you like

Origin www.cnblogs.com/codechange/p/11285532.html
Recommended