我有一个类进行本机调用来验证用户。在任何给定的时间点,该类可以有50-100个对象试图验证用户。本机调用函数的执行时间以毫秒为单位,但是当它返回结果时,结果将映射到另一个对象,因为验证失败。
例如 -
public class AS400Invoker {
native String authenticateUser(String message, String channelNo);
native String changePin(String message, String channelNo);
private Logger logger = Logger.getLogger(AS400Invoker.class);
static {
System.loadLibrary(PropertiesBean.readProperty("libraryname"));
}
public String userAuthetication(String ucid, String phoneCode, String pin, String channelNo){
String toRet = null;
try {
logger.info("["+ucid+"] Inside user authentication function");
logger.info("["+ucid+"] phone code received from IVR: "+phoneCode);
logger.info("["+ucid+"] channel number received from IVR: "+channelNo);
UserAuthentication ua = new UserAuthentication();
String formedMessage = ua.authenticateUser(ucid, phoneCode, pin);
logger.info("["+ucid+"] user authentication formed message length: "+formedMessage.length());
logger.info("["+ucid+"] calling native function to authenticate user....");
if(null != formedMessage)
toRet = authenticateUser(formedMessage, channelNo);
logger.info("["+ucid+"] response received from native function: "+toRet);
}catch(RuntimeException e){
logger.error("["+ucid+"] Runtime exception occured", e);
}catch(Exception e){
logger.error("["+ucid+"] Generic exception occured", e);
}
return toRet;
}
public String pinChange(String ucid, String phoneCode, String pin, String cif, String channelNo){
String toRet = null;
try {
logger.info("["+ucid+"] Inside pin change function");
logger.info("["+ucid+"] phone code received from IVR: "+phoneCode);
logger.info("["+ucid+"] CIF received from IVR: "+cif);
logger.info("["+ucid+"] channel number received from IVR: "+channelNo);
PinChange pc = new PinChange();
String formedMessage = pc.changePin(ucid, phoneCode, pin, cif);
logger.info("["+ucid+"] pin change formed message length: "+formedMessage.length());
logger.info("["+ucid+"] calling native function to change the pin....");
if(null != formedMessage)
toRet = changePin(formedMessage, channelNo);
logger.info("["+ucid+"] response received from native function: "+toRet);
}catch(RuntimeException e){
logger.error("["+ucid+"] Runtime exception occured", e);
}catch(Exception e){
logger.error("["+ucid+"] Generic exception occured", e);
}
return toRet;
}
}
在上面的场景中,原生呼叫的结果变得混乱。你们中的任何一个人都可以对这些电话中可能出现的问题有所了解吗?以下是相同的日志片段。在下面的片段中,请求由UCID为00001081951348702252的对象引发,但响应被映射到不同的UCID 00001080011348671171,实际上,响应是针对00001081951348702252 UCID。
INFO 2012-09-27 07:30:58,046 [http-7080-2] (UserAuthentication.java:11) - [00001081951348702252] Inside User Authentication
INFO 2012-09-27 07:30:58,047 [http-7080-2] (UserAuthentication.java:21) - [00001081951348702252] Phone Code: 7447225
INFO 2012-09-27 07:30:58,047 [http-7080-2] (UserAuthentication.java:23) - [00001081951348702252] Pin code received
INFO 2012-09-27 07:30:58,048 [http-7080-2] (AS400Invoker.java:51) - [00001081951348702252] user authentication formed message length: 68
INFO 2012-09-27 07:30:58,048 [http-7080-2] (AS400Invoker.java:52) - [00001081951348702252] calling native function to authenticate user....
INFO 2012-09-27 07:30:58,201 [http-7080-13] (AS400Invoker.java:55) - [00001080011348671171] response received from native function: 000OCBC08100C1C000000000008zF 621372010937239879230990239023 9D0001641412549001 01 C HHHHH CULTURE PVT. LTD 201206449R XYZ