Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Native Function Returns value to a different caller object
    primarykey
    data
    text
    <p>I have one class which makes a native call to authenticate a user. At any given point of a time there can be 50-100 objects of this class trying to authenticate a user. The execution time for the native call function is in milliseconds but when it returns the result, the result gets mapped to a different object because of which the authentication fails.</p> <p>e.g -</p> <pre><code>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; } } </code></pre> <p>In the above scenario, the result from the native call gets jumbled up. Can any one of you please throw some light on what might be going wrong in these calls? Below is the Log snippet for the same. In the below snippet the request is raised by the object whose UCID is 00001081951348702252 but the response gets mapped to a different UCID 00001080011348671171 and in reality, the response is for 00001081951348702252 UCID.</p> <pre><code>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 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload