我使用@HystrixCommand打包RPC,如果不使用Hystrix,它将正常运行。该RPC不是微服务,而是普通的http
import React from 'react'
import { View, Text, ActivityIndicator, StyleSheet } from 'react-
native'
import firebase from 'firebase';
export default class Loading extends React.Component {
componentDidMount() {
// firebase.auth().onAuthStateChanged(user => {
// this.props.navigation.navigate(user ? 'Main' : 'Login')
// }) // for now to solve problem
}
render() {
return (
<View style={styles.container}>
<Text>Loading</Text>
<ActivityIndicator size="large" />
</View>
)
}
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#2C3E50',
justifyContent: 'center',
alignItems: 'center',
}
});
错误信息,例如:
@Override
@HystrixCommand(commandProperties = {@HystrixProperty( name ="execution.isolation.thread.timeoutInMilliseconds",value="5000")},fallbackMethod="doAccountQueryFallback")
public CBIBAcctQueryResponseVO doAccountQuery(@RequestBody CBIBAcctQueryRequestVO cbibAcctQueryRequestVO) {
//initialize message
// ....
try {
responseMessage = (AcctTypeInqResponse) HTTPUtil.sendHttp("http://********", inqRequest, *****.class);
} catch (RuntimeException e) {
//...
}
logger.debug("success");// 1
return cbibAcctQueryResponseVO;
}
public CBIBAcctQueryResponseVO doAccountQueryFallback(@RequestBody CBIBAcctQueryRequestVO cbibAcctQueryRequestVO){
//....
}
我更改@HystrixCommand属性的值。尽管我设置了很长时间,但它也会显示此异常,请// //不要调用fallback方法。
当我设置为100时,它显示此异常,执行// 1并调用fallback方法。 我怀疑它发送了几次吗?
当我设置1时,它不会显示此异常并调用fallback方法。 实际上是预期的。
doAccountQuery是一个微服务,并且doAccountQuery中有一个正常的http请求。我只想将此正常的HTTP请求与Hystrix打包在一起(不使用伪装)。但是,一旦在doAccountQuery上添加@ @HystrixCommand,微服务doAccountQuery本身就会超时,但它还会返回结果(重新传输?仅第一次传输)超时了?我不知道)
1也尝试
feign.RetryableException: Read timed out executing POST http://****/doAccountQuery
at feign.FeignException.errorExecuting(FeignException.java:67)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:104)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
at com.sun.proxy.$Proxy153.doAccountQuery(Unknown Source)
...
...
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
但没用
除了有时,异常会变成 连接超时,不执行// 1,甚至不调用回退方法!
我想要一些调试建议,谢谢!