- Improve code structuration,

- Fix Message Count = 0 handling,
- Fix printout.
This commit is contained in:
agibert 2008-12-04 15:02:16 +00:00
parent bc2254cab8
commit 542f5b9bd6

View File

@ -1,7 +1,7 @@
// $RCSfile: MQSLoad.java,v $
// $Revision: 1.14 $
// $Revision: 1.15 $
// $Name: $
// $Date: 2008/12/04 10:45:06 $
// $Date: 2008/12/04 15:02:16 $
// $Author: agibert $
/*
@ -35,24 +35,25 @@ import com.ibm.mq.*;
public class MQSLoad
{
private String MQSLoad_Revision = "$Revision: 1.14 $";
private String MQSLoad_Tag = "$Name: $";
private String MQSLoad_Date = "$Date: 2008/12/04 10:45:06 $";
private String MQSLoad_Author = "$Author: agibert $";
private MQQueueManager QMng = null;
private String QMng_Name = "";
private String MQSLoad_Revision = "$Revision: 1.15 $";
private String MQSLoad_Tag = "$Name: $";
private String MQSLoad_Date = "$Date: 2008/12/04 15:02:16 $";
private String MQSLoad_Author = "$Author: agibert $";
private MQQueueManager QMng = null;
private String QMng_Name = "";
private MQQueue MsgQ;
private String MsgQ_Name;
private int MsgQ_Open_Options = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;
private int Sleep_Time = 0;
private String Field_Break = "";
private String Message_Break = "\r\n";
private String Message_Tail = "";
private int Message_Skip = 0;
private int Message_Count = 0;
private int Repeat_Count = 1;
private int MsgQ_Open_Options = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;
private int Sleep_Time = 0;
private String Field_Break = "";
private String Message_Break = "\r\n";
private String Message_Tail = "";
private int Message_Skip = 0;
private int Message_Count = 0;
private int Repeat_Count = 1;
private boolean Keep_Message_Break = false;
private String File_Name;
private int Msg_Counter = 0;
@ -431,19 +432,21 @@ public class MQSLoad
//
//-------------------------------------------------------------------------------------------------------------------------
private void Counter_Print( int Msg_Nb)
private void Counter_Print( String Mark)
{
if( ( Msg_Nb % 50) == 0)
if( ( Msg_Counter % 50) == 0)
{
System.out.print( "\n(" + Msg_Nb + ")\t");
System.out.print( "\n(" + Msg_Counter + ")\t");
}
if( ( Msg_Nb % 10) == 0)
if( ( Msg_Counter % 10) == 0)
{
System.out.print( " ");
}
System.out.print( ".");
System.out.print( Mark);
Msg_Counter++;
}
@ -480,24 +483,33 @@ public class MQSLoad
//
//-------------------------------------------------------------------------------------------------------------------------
private int Put_Msg( MQMessage Output_Msg, int Count_Nb, int Msg_Nb) throws Exception
private int Put_Msg( MQMessage Output_Msg, int Msg_Id, int Msg_Nb, int Msg_Skip, int Msg_Count) throws Exception
{
if( Msg_Nb > Count_Nb)
if( Msg_Id < Msg_Skip)
{
// System.out.print( "#");
Counter_Print( "*");
}
else
{
Output_Msg.messageId = MQC.MQMI_NONE;
MQSPut_Msg( Output_Msg);
Output_Msg.clearMessage();
Counter_Print( Msg_Nb++);
if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count)))
{
Counter_Print( "#");
}
else
{
Output_Msg.messageId = MQC.MQMI_NONE;
MQSPut_Msg( Output_Msg);
Output_Msg.clearMessage();
Counter_Print( ".");
Msg_Nb++;
Stand_By( Sleep_Time);
Stand_By( Sleep_Time);
}
}
return( Msg_Nb);
return(Msg_Nb);
}
@ -508,14 +520,13 @@ public class MQSLoad
//
//-------------------------------------------------------------------------------------------------------------------------
private int Load_File( RandomAccessFile Input_File, int Msg_Skip, int Msg_Count, int Msg_Nb) throws Exception
private int Load_File( RandomAccessFile Input_File, int Msg_Nb, int Msg_Skip, int Msg_Count) throws Exception
{
byte input_char;
MQMessage output_msg = new MQMessage();
int buffer_size, cur_buffer_size, window_size, cur_window_size, prefetch_size, buffer_offset, read_size;
int cur_pos, end_pos, next_message, next_field;
int skip_nb = 0;
int count_nb = Msg_Nb + Msg_Count;
int msg_id = 0;
byte[] buffer_byte;
String buffer_string, out_string = null;
@ -601,7 +612,7 @@ public class MQSLoad
if( next_message <= cur_window_size)
{
/* A message break has been found: send the data... */
// System.out.println( "* Write Msg CurPos: (" + cur_pos + ")");
// System.out.println( "* Write Msg CurPos: (" + cur_pos + ")");
output_msg.writeString( Message_Tail);
if( Keep_Message_Break)
@ -609,17 +620,10 @@ public class MQSLoad
output_msg.writeString( Message_Break);
}
if( skip_nb < Msg_Skip)
{
skip_nb++;
// System.out.print( "*");
}
else
{
Msg_Nb = Put_Msg( output_msg, count_nb, Msg_Nb);
}
// System.out.println( "(" + Msg_Nb + ")");
Msg_Nb = Put_Msg( output_msg, msg_id, Msg_Nb, Msg_Skip, Msg_Count);
msg_id++;
out_string = null;
cur_pos += Message_Break.length();
}
@ -638,8 +642,8 @@ public class MQSLoad
if( out_string != null)
{
// System.out.println( "* Flushing Msg");
Msg_Nb = Put_Msg( output_msg, count_nb, Msg_Nb);
// System.out.println( "* Flushing Msg");
Msg_Nb = Put_Msg( output_msg, msg_id, Msg_Nb, Msg_Skip, Msg_Count);
}
return( Msg_Nb);
@ -741,7 +745,7 @@ public class MQSLoad
}
}
msg_nb = Load_File( input_file, Message_Skip, Message_Count, msg_nb);
msg_nb = Load_File( input_file, msg_nb, Message_Skip, Message_Count);
}
time_end = System.currentTimeMillis();