Skip to main content

Getting worng object in cluster env

1 reply [Last post]
rajuuser
Offline
Joined: 2009-09-04

Hi All,

My application behaivour changes when the server is heavy loaded in generating a sequence no and writing to a file in the following scenario.

1) When i submit a form data, server will get the sequence no from oracle, which use the same to wirte the form data in to file.It dehaves normally when i submitted in local [Windows]. EX: form1 submitted, it will generate seqno 1 and wirte to file as 1.xml, if i open file the seqno will be 1.

But when the server load is high, what ever seqno genarating is different with file name and in the content of file.

Below is the snippet of code, pls., help to get out this issue.

// generates seqno
String msgid= msgutil.getNextMsgID(conn); oSeaLDP.setMsgId(msgid);
LDPMessage msg = (LDPMessage) oSEALDPTransformer.createSEALDPSUB(oSeaLDP);

String msgString = generator.generate(msg);// Generate XML

// Writing to file is in other object [other java class]
String msgid=msg.getMsgId();
String jmststamp=String.valueOf(msg.getJmsTimeStamp());
// File has no msgid and no jmstimestamp Address+lastpartof Current Time millis
String t=String.valueOf(System.currentTimeMillis());
String ms= t.substring(5,t.length());

if(msgid !=null && msgid.trim().length()>0){
filename=msg.getMsgId()+"."+filetype;
}else if(jmststamp !=null && jmststamp.trim().length() >0){
filename=msg.getJmsTimeStamp()+"."+filetype;
}else{
//filename=msg.getAddress()+ms+"."+filetype;
filename=msg.getOriginAddress()+ms+"."+filetype;
}

Application deployed in cluster env.
Any suggestions will really help me.

With regards,
Raj

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
walterln
Offline
Joined: 2007-04-17

Looking at the code it will happen when you handle two request in the same millisecond from the same source or when they have the same jms time stamp.
So you could use the Oracle sequence number in the file name or use File#createTempFile().