public interface HelloService {
HelloDTO sayHello();
}
public class HelloDTO implements Serializable {
private Integer id;
private String name;
public HelloDTO(Integer id, String name) {
this.id = id;
this.name = name;
}
@Override
public String toString() {
return "HelloDTO{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@Service
@PhoenixService(interfaceClass = HelloService.class)
public class HelloServiceImpl implements HelloService {
public HelloDTO sayHello() {
return new HelloDTO(1, "abc");
}
}
@Configuration
public class RpcConfig {
@Bean
public ServiceInitializer nettyServerAware() {
return new ServiceInitializer("127.0.0.1", 9998, "127.0.0.1:8848");
}
}
@RestController
public class HelloController {
@PhoenixReference
private HelloService helloService;
@GetMapping("/hello")
public HelloDTO sayHello() throws InterruptedException {
return helloService.sayHello();
}
}
@Configuration
public class RpcConfig {
@Bean
public ReferenceInitializer nettyServerAware() {
return new ReferenceInitializer("127.0.0.1:8848");
}
}
// todo