JSF is a fully developed high-performance RPC framework.
JSF Feature:
- TCP and HTTP protocol
- REST protocol service
- Serialization formats such as MsgPack,JSON,Hessian
- Data Compression
- Multiple LB strategies and cluster strategies
- Synchronous and asynchronous invocation
- Extended filter framework
- Active connection health checking
Documentation:
Quick Start
- Establish project and introduce JSF
- Implement and publish provider service
- Implement consumer
Simple Example
- Spring+XML Mode
1.1) Publish provider
<bean id="helloService" class="com.ipd.testjsf.HelloServiceImpl"/>
<jsf:server id="jsf" protocol="jsf" port="9090"/>
<jsf:provider id="helloServiceExport" interface="com.ipd.testjsf.HelloService"
ref="helloService" server="jsf" alias="JSF:0.0.1" register="false">
</jsf:provider>
1.2) Start consumer
<jsf:consumer id="helloService" interface="com.ipd.testjsf.HelloService" retries="0"
protocol="jsf" alias="JSF:0.0.1" timeout="60000" url="jsf://127.0.0.1:9090">
</jsf:consumer>
- Api Mode
2.1) Publish provider
public static void main(String[] args) throws UnsupportedEncodingException {
HelloService helloService = new HelloServiceImpl();
ServerConfig serverConfig = new ServerConfig();
serverConfig.setProtocol("jsf");
logger.info("ServerConfig");
ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>();
providerConfig.setInterfaceId("com.ipd.testjsf.HelloService");
providerConfig.setRef(helloService);
providerConfig.setAlias("JSF:0.0.1");
providerConfig.setServer(serverConfig);
logger.info("ProviderConfig");
providerConfig.export();
logger.info("Publishing is finished");
synchronized (ServerMainAPI.class) {
while (true) {
try {
ServerMainAPI.class.wait();
} catch (InterruptedException e) {
}
}
}
}
2.2) Start consumer
public static void main(String[] args){
ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>();
consumerConfig.setInterfaceId("com.ipd.testjsf.HelloService");
consumerConfig.setProtocol("jsf");
consumerConfig.setAlias("JSF:0.0.1");
consumerConfig.setUrl("jsf://127.0.0.1:22000;jsf://127.0.0.1:22001");
logger.info("ConsumerConfig");
HelloService service = consumerConfig.refer();
while (true) {
try {
String result = service.echoStr("string put");
logger.info("result msg:{}", result);
} catch (Exception e) {
logger.error("",e);
}
try {
Thread.sleep(3000);
} catch (Exception e) {
}
}
}