RPC 远程调用超时
@少帮主 你好,想跟你请教个问题:
import java.io.IOException;
import org.zbus.broker.Broker;
import org.zbus.broker.BrokerConfig;
import org.zbus.broker.SingleBroker;
import org.zbus.kit.ConfigKit;
import org.zbus.rpc.RpcProcessor;
import org.zbus.rpc.mq.Service;
import org.zbus.rpc.mq.ServiceConfig;
import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;
public class RPCService {
private Prop prop = PropKit.use("play.properties");
private String ip = prop.get("zbus.host");
private String port = prop.get("zbus.port");
private ServiceConfig config;
private Service svc;
private boolean isStart = false;
public boolean isStart() {
return isStart;
}
public RPCService(){
final String serverAddress = ConfigKit.option(new String[]{}, "-b", ip+":"+port);
final int threadCount = ConfigKit.option(new String[]{}, "-c", 32);
final String mq = ConfigKit.option(new String[]{}, "-mq", "RPCMessageCenter");
RpcProcessor processor = new RpcProcessor();
//增加模块,模块名在调用时需要指定
processor.addModule(new MessageService());
//配置Broker
BrokerConfig brokerCfg = new BrokerConfig();
brokerCfg.setServerAddress(serverAddress);
/*brokerCfg.setMaxTotal(threadCount);
brokerCfg.setMinIdle(threadCount);*/
Broker broker = null;
try {
broker = new SingleBroker(brokerCfg);
} catch (IOException e) {
e.printStackTrace();
}
config = new ServiceConfig();
//config.setConsumerCount(threadCount);
config.setMq(mq);
config.setBroker(broker);
config.setMessageProcessor(processor);
svc = new Service(config);
}
public boolean start(){
try {
svc.start();
isStart = true;
return isStart;
} catch (IOException e) {
e.printStackTrace();
return isStart;
}
}
}
报错:
Exception in thread "Thread-9" org.zbus.mq.MqException: {"@type":"org.zbus.rpc.RpcCodec$Request","encoding":"UTF-8","method":"sendMessage","module":"","paramTypes":null,"params":["{"from":"Test","to":"fb6d56af5fdd4ce9b49ee0f865f83354"}"]}
at org.zbus.mq.Consumer.recv(Consumer.java:88)
at org.zbus.mq.Consumer$1.run(Consumer.java:145)
at java.lang.Thread.run(Thread.java:745)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
超时的原因分析:
1. service端异常
2. service执行时间过长,导致超时。
建议service单个方法不要执行长时间任务。可拆分为多个接口!
timeout时间设置长点呐