Compare commits
No commits in common. "master" and "mqsload-1_3_2" have entirely different histories.
master
...
mqsload-1_
548
MQSLoad.java
548
MQSLoad.java
@ -1,12 +1,12 @@
|
|||||||
// $RCSfile: MQSLoad.java,v $
|
// $RCSfile: MQSLoad.java,v $
|
||||||
// $Revision: 1.22 $
|
// $Revision: 1.13 $
|
||||||
// $Name: $
|
// $Name: $
|
||||||
// $Date: 2013/11/08 17:15:45 $
|
// $Date: 2008/11/14 00:00:51 $
|
||||||
// $Author: agibert $
|
// $Author: agibert $
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MQSLoad.java - Data file to MQ/Series queue loader
|
* MQSLoad.java - Data file to MQ/Series queue loader
|
||||||
* Copyright (C) 2001-2008 Arnaud G. Gibert
|
* Copyright (C) 2001-2006 Arnaud G. Gibert
|
||||||
* mailto:arnaud@rx3.net
|
* mailto:arnaud@rx3.net
|
||||||
* http://www.rx3.org/dvp/MQSLoad
|
* http://www.rx3.org/dvp/MQSLoad
|
||||||
*
|
*
|
||||||
@ -25,38 +25,31 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.ibm.mq.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.text.*;
|
import java.text.*;
|
||||||
import com.ibm.mq.*;
|
|
||||||
import com.ibm.mq.constants.*;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class MQSLoad
|
public class MQSLoad
|
||||||
{
|
{
|
||||||
private String MQSLoad_Revision = "$Revision: 1.22 $";
|
|
||||||
private String MQSLoad_Tag = "$Name: $";
|
|
||||||
private String MQSLoad_Date = "$Date: 2013/11/08 17:15:45 $";
|
|
||||||
private String MQSLoad_Author = "$Author: agibert $";
|
|
||||||
private MQQueueManager QMng = null;
|
private MQQueueManager QMng = null;
|
||||||
private String QMng_Name = "";
|
private String QMng_Name = "";
|
||||||
private MQQueue MsgQ;
|
private MQQueue MsgQ;
|
||||||
private String MsgQ_Name;
|
private String MsgQ_Name;
|
||||||
private int MsgQ_Open_Options = CMQC.MQOO_OUTPUT | CMQC.MQOO_FAIL_IF_QUIESCING;
|
private int MsgQ_Open_Options = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;
|
||||||
private boolean Character_Convert = false;
|
private String File_Name;
|
||||||
private int Character_Set = 1208;
|
|
||||||
private int Message_Priority = CMQC.MQPRI_PRIORITY_AS_Q_DEF;
|
|
||||||
private int Sleep_Time = 0;
|
|
||||||
private String Field_Break = "";
|
private String Field_Break = "";
|
||||||
private String Message_Break = "\r\n";
|
private String Message_Break = "\r\n";
|
||||||
private String Message_Tail = "";
|
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 boolean Keep_Message_Break = false;
|
||||||
private String File_Name;
|
private String MQSLoad_Revision = "$Revision: 1.13 $";
|
||||||
private int Msg_Counter = 0;
|
private String MQSLoad_Tag = "$Name: $";
|
||||||
private int Msg_Read_Nb = 0;
|
private String MQSLoad_Date = "$Date: 2008/11/14 00:00:51 $";
|
||||||
private int Msg_Skiped_Nb = 0;
|
private String MQSLoad_Author = "$Author: agibert $";
|
||||||
|
private Integer Sleep_Time = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -202,7 +195,7 @@ public class MQSLoad
|
|||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
private void Args_Parse( String args[]) throws Exception
|
private void Arg_Parse( String args[]) throws Exception
|
||||||
{
|
{
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
|
|
||||||
@ -223,46 +216,6 @@ public class MQSLoad
|
|||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( args[argc].equals( "-cc"))
|
|
||||||
{
|
|
||||||
Character_Convert = true;
|
|
||||||
}
|
|
||||||
else if ( args[argc].equals( "-cs"))
|
|
||||||
{
|
|
||||||
if( argc < ( args.length + 1))
|
|
||||||
{
|
|
||||||
Character_Set = Integer.parseInt( args[++argc]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println( "Invalid number of command line options...");
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( args[argc].equals( "-mp"))
|
|
||||||
{
|
|
||||||
if( argc < ( args.length + 1))
|
|
||||||
{
|
|
||||||
Message_Priority = Integer.parseInt( args[++argc]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println( "Invalid number of command line options...");
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( args[argc].equals( "-st"))
|
|
||||||
{
|
|
||||||
if( argc < ( args.length + 1))
|
|
||||||
{
|
|
||||||
Sleep_Time = Integer.parseInt( args[++argc]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println( "Invalid number of command line options...");
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( args[argc].equals( "-fb"))
|
else if( args[argc].equals( "-fb"))
|
||||||
{
|
{
|
||||||
if( argc < ( args.length + 1))
|
if( argc < ( args.length + 1))
|
||||||
@ -299,35 +252,11 @@ public class MQSLoad
|
|||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( args[argc].equals( "-ms"))
|
else if ( args[argc].equals( "-st"))
|
||||||
{
|
{
|
||||||
if( argc < ( args.length + 1))
|
if( argc < ( args.length + 1))
|
||||||
{
|
{
|
||||||
Message_Skip = Integer.parseInt( args[++argc]);
|
Sleep_Time = Integer.parseInt( args[++argc]);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println( "Invalid number of command line options...");
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( args[argc].equals( "-mc"))
|
|
||||||
{
|
|
||||||
if( argc < ( args.length + 1))
|
|
||||||
{
|
|
||||||
Message_Count = Integer.parseInt( args[++argc]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println( "Invalid number of command line options...");
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( args[argc].equals( "-rc"))
|
|
||||||
{
|
|
||||||
if( argc < ( args.length + 1))
|
|
||||||
{
|
|
||||||
Repeat_Count = Integer.parseInt( args[++argc]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -463,106 +392,19 @@ public class MQSLoad
|
|||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
private int Buffer_Lookup( byte[] Buffer, int Offset, int End, byte[] Message_Break)
|
private void Counter_Print( int Msg_Nb)
|
||||||
{
|
{
|
||||||
int i = Offset;
|
if( ( Msg_Nb % 50) == 0)
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
|
|
||||||
while( ( i < End) && ( j < Message_Break.length))
|
|
||||||
{
|
{
|
||||||
if( Buffer[i++] == Message_Break[j])
|
System.out.print( "\n(" + Msg_Nb + ")\t");
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( j == Message_Break.length)
|
if( ( Msg_Nb % 10) == 0)
|
||||||
{
|
|
||||||
return( i - j);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return( -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
private void Msg_Write( MQMessage Msg, byte[] Buffer, int Offset, int End, byte[] Field_Break) throws Exception
|
|
||||||
{
|
|
||||||
int cur_pos = Offset;
|
|
||||||
int fld_break;
|
|
||||||
|
|
||||||
|
|
||||||
/* scan into the buffer */
|
|
||||||
while( cur_pos < End)
|
|
||||||
{
|
|
||||||
if( Field_Break.length == 0)
|
|
||||||
{
|
|
||||||
/* No Field Break */
|
|
||||||
// System.out.println( "* Skip FB Lookup...");
|
|
||||||
|
|
||||||
fld_break = End;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Field Break Lookup */
|
|
||||||
// System.out.println( "* FB Lookup: (" + fld_break + ")");
|
|
||||||
|
|
||||||
fld_break = Buffer_Lookup( Buffer, cur_pos, End, Field_Break);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( fld_break == -1)
|
|
||||||
{
|
|
||||||
/* Write the rest of the buffer */
|
|
||||||
// System.out.println( "* Last Field");
|
|
||||||
|
|
||||||
fld_break = End;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write to MQ-Message */
|
|
||||||
// System.out.println( "* Write Field: cur_pos(" + cur_pos + ") Len: (" + ( fld_break - cur_pos) + ")");
|
|
||||||
|
|
||||||
Msg.write( Buffer, cur_pos, ( fld_break - cur_pos));
|
|
||||||
|
|
||||||
cur_pos = fld_break + Field_Break.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
private void Counter_Print( String Mark)
|
|
||||||
{
|
|
||||||
if( ( Msg_Counter % 50) == 0)
|
|
||||||
{
|
|
||||||
System.out.print( "\n(" + Msg_Counter + ")\t");
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( Msg_Counter % 10) == 0)
|
|
||||||
{
|
{
|
||||||
System.out.print( " ");
|
System.out.print( " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.print( Mark);
|
System.out.print( ".");
|
||||||
|
|
||||||
Msg_Counter++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -573,7 +415,7 @@ public class MQSLoad
|
|||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
private void Stand_By(int timer) throws Exception
|
private void Stand_By(int timer)
|
||||||
{
|
{
|
||||||
if( timer > 0)
|
if( timer > 0)
|
||||||
{
|
{
|
||||||
@ -599,184 +441,142 @@ public class MQSLoad
|
|||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
private boolean Msg_Put( MQMessage Output_Msg, int Msg_Id, int Msg_Skip, int Msg_Count) throws Exception
|
private int Load_File( BufferedInputStream Input_File) throws Exception
|
||||||
{
|
{
|
||||||
if( Msg_Id < Msg_Skip)
|
byte input_char;
|
||||||
|
int msg_nb = 0;
|
||||||
|
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;
|
||||||
|
byte[] buffer_byte;
|
||||||
|
String buffer_string, out_string = null;
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Counter_Print( "#");
|
output_msg.format = MQC.MQFMT_STRING;
|
||||||
Msg_Skiped_Nb++;
|
|
||||||
|
|
||||||
|
/* Default window size */
|
||||||
|
window_size = 1024 * 64;
|
||||||
|
prefetch_size = Field_Break.length() + Message_Break.length();
|
||||||
|
buffer_size = window_size + prefetch_size;
|
||||||
|
|
||||||
|
buffer_offset = 0;
|
||||||
|
|
||||||
|
buffer_byte = new byte[buffer_size];
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
read_size = Input_File.read( buffer_byte, buffer_offset, buffer_size - buffer_offset);
|
||||||
|
// System.out.println( "Load buffer read_size: (" + read_size + ") asked: (" + (buffer_size - buffer_offset) + ")");
|
||||||
|
|
||||||
|
if( read_size == -1)
|
||||||
|
{
|
||||||
|
read_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compute current buffer and window size */
|
||||||
|
cur_window_size = Math.min( ( read_size + buffer_offset), window_size);
|
||||||
|
cur_buffer_size = ( read_size + buffer_offset);
|
||||||
|
|
||||||
|
buffer_string = new String( buffer_byte, 0, cur_buffer_size);
|
||||||
|
cur_pos = 0;
|
||||||
|
|
||||||
|
// System.out.println( " CurWS: (" + cur_window_size + ") CurBS: (" + cur_buffer_size + ") Buffer: [" + buffer_string + "]");
|
||||||
|
|
||||||
|
while( cur_pos < cur_window_size)
|
||||||
|
{
|
||||||
|
// System.out.println( "- CurPos: (" + cur_pos + ")");
|
||||||
|
next_message = buffer_string.indexOf( Message_Break, cur_pos);
|
||||||
|
|
||||||
|
if( ( next_message == -1) || ( next_message > cur_window_size))
|
||||||
|
{
|
||||||
|
next_message = cur_window_size + 1;
|
||||||
|
end_pos = cur_window_size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count)))
|
// System.out.println( "+ Get message next_message: (" + next_message + ")");
|
||||||
|
end_pos = next_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
while( cur_pos < end_pos)
|
||||||
{
|
{
|
||||||
Counter_Print( "*");
|
// System.out.println( "+ CurPos: (" + cur_pos + ") end_pos: (" + end_pos + ")");
|
||||||
Msg_Skiped_Nb++;
|
if( Field_Break.length() > 0)
|
||||||
|
{
|
||||||
|
next_field = buffer_string.indexOf( Field_Break, cur_pos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Output_Msg.messageId = CMQC.MQMI_NONE;
|
next_field = -1;
|
||||||
MQSPut_Msg( Output_Msg);
|
}
|
||||||
Output_Msg.clearMessage();
|
|
||||||
|
|
||||||
Counter_Print( ".");
|
if( ( next_field == -1) || ( next_field > end_pos))
|
||||||
|
{
|
||||||
|
out_string = buffer_string.substring( cur_pos, end_pos);
|
||||||
|
cur_pos = end_pos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// System.out.println( "+ Get field next_field: (" + next_field + ")");
|
||||||
|
out_string = buffer_string.substring( cur_pos, next_field);
|
||||||
|
cur_pos = next_field + Field_Break.length();
|
||||||
|
}
|
||||||
|
|
||||||
Msg_Read_Nb++;
|
output_msg.writeString( out_string);
|
||||||
|
// System.out.println( "* Msg: [" + out_string + "]");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if( next_message <= cur_window_size)
|
||||||
|
{
|
||||||
|
/* A message break has been found: send the data... */
|
||||||
|
// System.out.println( "* Write Msg CurPos: (" + cur_pos + ")");
|
||||||
|
output_msg.writeString( Message_Tail);
|
||||||
|
|
||||||
|
if( Keep_Message_Break)
|
||||||
|
{
|
||||||
|
output_msg.writeString( Message_Break);
|
||||||
|
}
|
||||||
|
|
||||||
|
output_msg.messageId = MQC.MQMI_NONE;
|
||||||
|
MQSPut_Msg( output_msg);
|
||||||
|
output_msg.clearMessage();
|
||||||
|
out_string = null;
|
||||||
|
cur_pos += Message_Break.length();
|
||||||
|
|
||||||
|
Counter_Print( msg_nb++);
|
||||||
|
|
||||||
Stand_By( Sleep_Time);
|
Stand_By( Sleep_Time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg_Id++;
|
buffer_offset = cur_buffer_size - cur_pos;
|
||||||
|
// System.out.println( "% CurPos: (" + cur_pos + ") BufOff: (" + buffer_offset + ")");
|
||||||
|
|
||||||
if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count)))
|
if( buffer_offset > 0)
|
||||||
{
|
|
||||||
/* Last Message to be read */
|
|
||||||
return( false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return( true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
private void File_Load( RandomAccessFile Input_File, int Msg_Skip, int Msg_Count) throws Exception
|
|
||||||
{
|
|
||||||
MQMessage output_msg = new MQMessage();
|
|
||||||
byte[] buffer;
|
|
||||||
byte[] message_break = Message_Break.getBytes();
|
|
||||||
byte[] field_break = Field_Break.getBytes();
|
|
||||||
byte[] message_tail = Message_Tail.getBytes();
|
|
||||||
int buf_size, work_win_size, break_win_size, prefetch_size, fetch_size;
|
|
||||||
int cur_buf_size, cur_work_win_size, cur_pos, msg_break;
|
|
||||||
int msg_id = 0;
|
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if( Character_Convert)
|
|
||||||
{
|
|
||||||
output_msg.format = CMQC.MQFMT_STRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
output_msg.characterSet = Character_Set;
|
|
||||||
output_msg.priority = Message_Priority;
|
|
||||||
|
|
||||||
work_win_size = 1024 * 64;
|
|
||||||
break_win_size = Field_Break.length() + message_break.length;
|
|
||||||
|
|
||||||
buf_size = work_win_size + break_win_size;
|
|
||||||
buffer = new byte[buf_size];
|
|
||||||
|
|
||||||
prefetch_size = 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
/* Fill the buffer */
|
|
||||||
do
|
|
||||||
{
|
|
||||||
fetch_size = Input_File.read( buffer, prefetch_size, buf_size - prefetch_size);
|
|
||||||
// System.out.println( "Load buffer fetch_size: (" + fetch_size + ") asked: (" + (buf_size - prefetch_size) + ")");
|
|
||||||
|
|
||||||
if( fetch_size == -1)
|
|
||||||
{
|
|
||||||
fetch_size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* compute the current buffer size, work window size and new prefetch size */
|
|
||||||
cur_buf_size = prefetch_size + fetch_size;
|
|
||||||
cur_work_win_size = Math.min( work_win_size, cur_buf_size);
|
|
||||||
|
|
||||||
if( cur_buf_size < break_win_size)
|
|
||||||
{
|
|
||||||
prefetch_size = cur_buf_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_pos = 0;
|
|
||||||
|
|
||||||
// System.out.println( " Cur Work Win Size: (" + cur_work_win_size + ") Cur Buf Size: (" + cur_buf_size + ") Prefetch Size: (" + prefetch_size + ")");
|
|
||||||
}
|
|
||||||
while( ( fetch_size != 0) && ( cur_buf_size < break_win_size));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* scan into the work window */
|
|
||||||
while( cur_pos < cur_work_win_size)
|
|
||||||
{
|
|
||||||
// System.out.println( "- CurPos: (" + cur_pos + ")");
|
|
||||||
|
|
||||||
msg_break = Buffer_Lookup( buffer, cur_pos, cur_buf_size, message_break);
|
|
||||||
|
|
||||||
if( msg_break == -1)
|
|
||||||
{
|
|
||||||
/* write the message to the MQ buffer */
|
|
||||||
// System.out.println( "+ No msg break");
|
|
||||||
// System.out.println( "* Write MQ Buffer Offset: (" + cur_pos + ") End: (" + cur_work_win_size + ")");
|
|
||||||
Msg_Write( output_msg, buffer, cur_pos, cur_work_win_size, field_break);
|
|
||||||
|
|
||||||
cur_pos = cur_work_win_size;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// System.out.println( "+ Get msg break : (" + msg_break + ")");
|
|
||||||
|
|
||||||
/* write the message to the MQ buffer */
|
|
||||||
Msg_Write( output_msg, buffer, cur_pos, msg_break, field_break);
|
|
||||||
|
|
||||||
/* write the message tail to the MQ buffer */
|
|
||||||
output_msg.write( message_tail, 0, message_tail.length);
|
|
||||||
|
|
||||||
if( Keep_Message_Break)
|
|
||||||
{
|
|
||||||
/* write the message break to the MQ buffer */
|
|
||||||
// System.out.println( "* Write MQ Buffer Offset: (" + cur_pos + ") End: (" + ( msg_break + message_break.length) + ")");
|
|
||||||
output_msg.write( buffer, msg_break, message_break.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* send the message */
|
|
||||||
// System.out.println( "* Put Msg()");
|
|
||||||
|
|
||||||
if( Msg_Put( output_msg, msg_id, Msg_Skip, Msg_Count) == false)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_id++;
|
|
||||||
cur_pos = msg_break + message_break.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
prefetch_size = cur_buf_size - cur_pos;
|
|
||||||
// System.out.println( "- Prefetch size: (" + prefetch_size + ")");
|
|
||||||
|
|
||||||
if( prefetch_size > 0)
|
|
||||||
{
|
{
|
||||||
/* Copy back prefetch area */
|
/* Copy back prefetch area */
|
||||||
System.arraycopy( buffer, cur_pos, buffer, 0, prefetch_size);
|
System.arraycopy( buffer_byte, cur_pos, buffer_byte, 0, buffer_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( cur_buf_size > 0);
|
while( cur_buffer_size > 0);
|
||||||
|
|
||||||
|
if( out_string != null)
|
||||||
|
|
||||||
if( output_msg.getMessageLength() > 0)
|
|
||||||
{
|
{
|
||||||
/* flush the message */
|
// System.out.println( "* Flushing Msg");
|
||||||
// System.out.println( "* Put Msg()");
|
output_msg.messageId = MQC.MQMI_NONE;
|
||||||
Msg_Put( output_msg, msg_id, Msg_Skip, Msg_Count);
|
MQSPut_Msg( output_msg);
|
||||||
|
|
||||||
|
Counter_Print( msg_nb++);
|
||||||
|
|
||||||
|
Stand_By( Sleep_Time);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
System.out.println( "\n");
|
||||||
|
return( msg_nb);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch( Exception Expt)
|
catch( Exception Expt)
|
||||||
@ -789,108 +589,59 @@ public class MQSLoad
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
private void Usage_Print( ) throws Exception
|
|
||||||
{
|
|
||||||
System.out.println( "Usage: MQSLoad [-qm \"Output_QueueMng_Name\"] [-cc] [-cs \"character_set\"] [-mp \"message_priority\"] [-st \"sleep_time\"] [-fb \"field_break\"] [-mb \"message_break\"] [-mt \"message_tail\"] [-kmb] [-ms \"message_skip\"] [-mc \"message_count\"] [-rc \"repeat_count\"] <Output_MsgQueue_Name> <Input_File_Name>");
|
|
||||||
System.out.println( "");
|
|
||||||
System.out.println( " Default: Output QueueMng Name: (" + QMng_Name + ") Character Convert: (" + Character_Convert + ") Character Set: (" + Character_Set + ") Message Priority: (" + Message_Priority + ") Sleep Time: (" + Sleep_Time + ") Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Message Tail: (" + Str_UnFormat( Message_Tail) + ") Keep Message Break: (" + Keep_Message_Break + ") Message Skip: (" + Message_Skip + ") Message Count: (" + Message_Count + ") Repeat Count: (" + Repeat_Count + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
private void Args_Print( ) throws Exception
|
|
||||||
{
|
|
||||||
System.out.println( "Output QueueMng Name: (" + QMng_Name + ") Output MsgQueue Name: (" + MsgQ_Name + ") Input File Name: (" + File_Name + ")");
|
|
||||||
System.out.println( "Character Convert: (" + Character_Convert + ") Character Set: (" + Character_Set + ") Message Priority: (" + Message_Priority + ") Sleep Time: (" + Sleep_Time + ") Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Message Tail: (" + Str_UnFormat( Message_Tail) + ") Keep Message Break: (" + Keep_Message_Break + ") Message Skip: (" + Message_Skip + ") Message Count: (" + Message_Count + ") Repeat Count: (" + Repeat_Count + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
public MQSLoad( String args[])
|
public MQSLoad( String args[])
|
||||||
{
|
{
|
||||||
int loop;
|
int msg_nb;
|
||||||
long time_begin, time_end;
|
long time_begin, time_end;
|
||||||
double time_elapsed, speed;
|
double time_elapsed, speed;
|
||||||
NumberFormat nf = NumberFormat.getInstance();
|
NumberFormat nf = NumberFormat.getInstance();
|
||||||
RandomAccessFile input_file = null;
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
System.out.println("MQSLoad: " + MQSLoad_Tag + " / " + MQSLoad_Date + " / " + MQSLoad_Author);
|
System.out.println("MQSLoad: " + MQSLoad_Tag + " / " + MQSLoad_Date + " / " + MQSLoad_Author);
|
||||||
|
|
||||||
if( ( args.length < 2) || ( args.length > 19))
|
if( ( args.length < 2) || ( args.length > 8))
|
||||||
{
|
{
|
||||||
Usage_Print();
|
System.out.println( "Usage: MQSLoad [-qm \"Output_QueueMng_Name\"] [-st \"sleep_time\"] [-fb \"field_break\"] [-mb \"message_break\"] [-mt \"message_tail\"] [-kmb] <Output_MsgQueue_Name> <Input_File_Name>");
|
||||||
|
System.out.println( " Default: Output QueueMng Name: (" + QMng_Name + ") Sleep Time: (" + Sleep_Time + ") Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Message Tail: (" + Str_UnFormat( Message_Tail) + ") Keep Message Break: (" + Keep_Message_Break + ")");
|
||||||
|
|
||||||
System.exit( 1);
|
System.exit( 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.out.println( "MQS Load Starting...");
|
System.out.println( "MQS Load Starting...");
|
||||||
|
|
||||||
Args_Parse( args);
|
Arg_Parse( args);
|
||||||
Args_Print();
|
|
||||||
|
System.out.println( "Output QueueMng Name: (" + QMng_Name + ") Output MsgQueue Name: (" + MsgQ_Name + ") Input File Name: (" + File_Name + ")");
|
||||||
|
System.out.println( "Sleep Time: (" + Sleep_Time + ") Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Message Tail: (" + Str_UnFormat( Message_Tail) + ") Keep Message Break: (" + Keep_Message_Break + ")");
|
||||||
|
|
||||||
MQSInit();
|
MQSInit();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
input_file = new RandomAccessFile( File_Name, "r");
|
BufferedInputStream input_file = new BufferedInputStream( new FileInputStream( File_Name));
|
||||||
|
|
||||||
System.out.println( "Legend: .: Loaded #: Skiped");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// System.out.println("Input File Open: (" + input_file + ") !");
|
// System.out.println("Input File Open: (" + input_file + ") !");
|
||||||
|
|
||||||
time_begin = System.currentTimeMillis();
|
time_begin = System.currentTimeMillis();
|
||||||
|
msg_nb = Load_File( input_file);
|
||||||
for( loop = 0; loop < Repeat_Count; loop++ )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
input_file.seek(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
catch( Exception Expt)
|
|
||||||
{
|
|
||||||
if( Repeat_Count > 1)
|
|
||||||
{
|
|
||||||
System.out.println( "Repeat Count should be 1 for non seekable file !");
|
|
||||||
throw Expt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File_Load( input_file, Message_Skip, Message_Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
time_end = System.currentTimeMillis();
|
time_end = System.currentTimeMillis();
|
||||||
|
|
||||||
time_elapsed = ( time_end - time_begin) / 1000.0;
|
time_elapsed = ( time_end - time_begin) / 1000.0;
|
||||||
speed = Msg_Read_Nb / time_elapsed;
|
speed = msg_nb / time_elapsed;
|
||||||
|
|
||||||
nf.setMinimumFractionDigits(2);
|
nf.setMinimumFractionDigits(2);
|
||||||
nf.setMaximumFractionDigits(2);
|
nf.setMaximumFractionDigits(2);
|
||||||
|
|
||||||
System.out.println( "\n");
|
System.out.println( "Loaded Message Nb: (" + msg_nb
|
||||||
System.out.println( "Loaded Message Nb: (" + Msg_Read_Nb
|
|
||||||
+ ") Skiped Messages Nb: (" + Msg_Skiped_Nb
|
|
||||||
+ ") Elapsed Time: (" + nf.format(time_elapsed)
|
+ ") Elapsed Time: (" + nf.format(time_elapsed)
|
||||||
+ ") s Speed: (" + nf.format(speed)
|
+ ") s Speed: (" + nf.format(speed)
|
||||||
+ ") msg/s");
|
+ ") msg/s");
|
||||||
@ -926,10 +677,5 @@ public class MQSLoad
|
|||||||
System.exit( 1);
|
System.exit( 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
45
ReadMe.txt
45
ReadMe.txt
@ -1,7 +1,7 @@
|
|||||||
# $RCSfile: ReadMe.txt,v $
|
# $RCSfile: ReadMe.txt,v $
|
||||||
# $Revision: 1.11 $
|
# $Revision: 1.8 $
|
||||||
# $Name: $
|
# $Name: $
|
||||||
# $Date: 2009/01/05 17:45:40 $
|
# $Date: 2007/12/11 16:46:37 $
|
||||||
# $Author: agibert $
|
# $Author: agibert $
|
||||||
|
|
||||||
|
|
||||||
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
Compilation:
|
Compilation:
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- Just type: "javac MQSLoad.java" !
|
- Just type: "javac MQSLoad.java" !
|
||||||
|
|
||||||
|
|
||||||
@ -22,42 +21,10 @@ Installation:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
------
|
|
||||||
|
|
||||||
MQSLoad [-qm "Output_QueueMng_Name"] [-cc] [-cs "character_set"] [-mp "message_priority"] [-st "sleep_time"] [-fb "field_break"] [-mb "message_break"] [-mt "message_tail"] [-kmb] [-ms "message_skip"] [-mc "message_count"] [-rc "repeat_count"] <Output_MsgQueue_Name> <Input_File_Name>
|
|
||||||
|
|
||||||
Default: Output QueueMng Name: () Character Convert: (false) Character Set: (1208) Message Priority: (-1) Sleep Time: (0) Field Break: () Message Break: (\r\n) Message Tail: () Keep Message Break: (false) Message Skip: (0) Message Count: (0) Repeat Count: (1)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
----------
|
|
||||||
|
|
||||||
- Optional arguments:
|
|
||||||
-qm "Output_QueueMng_Name": Name of the queue manager to use,
|
|
||||||
-cc "character_convert": Switch on the caracter conversion (Set the MQMessage format to MQC.MQFMT_STRING),
|
|
||||||
-cs "character_set": MQMessage character set,
|
|
||||||
-mp "message_priority": Priority of the message,
|
|
||||||
-st "sleep_time": Delay between message sending,
|
|
||||||
-fb "field_break": String used as field separator,
|
|
||||||
-mb "message_break": String used as message separator,
|
|
||||||
-mt "message_tail": String added at the message end,
|
|
||||||
-kmb "keep_message_break": Keep the message break (inserted at the message end, next to the message tail),
|
|
||||||
-ms "message_skip": Number of messages to skip before to start the loading,
|
|
||||||
-mc "message_count": Number of messages to load,
|
|
||||||
-rc "repeat_count": Number of time the whole process (start of file + skip + load) should be repeated.
|
|
||||||
|
|
||||||
- Mandatory arguments:
|
|
||||||
<Output_MsgQueue_Name>: Name of the output message queue to load to,
|
|
||||||
<Input_File_Name>: Name of the input file to load from.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
------
|
------
|
||||||
|
|
||||||
- MQSLoad has been tested with WMQ 6.0
|
- MQSLoad has been tested with MQ/Series 5.2, 5.3 and WMQ 6.0
|
||||||
|
|
||||||
- "-fb" and "-mb" arguments accept a string with formated escape character:
|
- "-fb" and "-mb" arguments accept a string with formated escape character:
|
||||||
+ "\n" for newline,
|
+ "\n" for newline,
|
||||||
@ -87,15 +54,9 @@ Usage Examples:
|
|||||||
|
|
||||||
- To load a swift batch file "swift-batch.txt" with "---MESSAGE-BREAK---" message separator into the MQ/Series "SWIFT-QUEUE" use:
|
- To load a swift batch file "swift-batch.txt" with "---MESSAGE-BREAK---" message separator into the MQ/Series "SWIFT-QUEUE" use:
|
||||||
java MQSLoad -mb "---MESSAGE-BREAK---\r\n" SWIFT-QUEUE swift-batch.txt
|
java MQSLoad -mb "---MESSAGE-BREAK---\r\n" SWIFT-QUEUE swift-batch.txt
|
||||||
|
|
||||||
- To load 10 time the third message of the file "swift-batch.txt" with "---MESSAGE-BREAK---" as message separator into the MQ/Series "SWIFT-QUEUE" use:
|
|
||||||
java MQSLoad -mb "---MESSAGE-BREAK---\r\n" -ms 2 -mc 1 -rc 10 SWIFT-QUEUE swift-batch.txt
|
|
||||||
|
|
||||||
- To load a raw swift batch file "swift-batch-raw.txt" with "}\r\n" message break into the MQ/Series "SWIFT-QUEUE" and by keeping message break separator use:
|
- To load a raw swift batch file "swift-batch-raw.txt" with "}\r\n" message break into the MQ/Series "SWIFT-QUEUE" and by keeping message break separator use:
|
||||||
java MQSLoad -mb "}\r\n" -kmb SWIFT-QUEUE swift-batch-raw.txt
|
java MQSLoad -mb "}\r\n" -kmb SWIFT-QUEUE swift-batch-raw.txt
|
||||||
|
|
||||||
- To load a raw swift batch file "swift-batch-raw.txt" with "}\r\n" message break into the MQ/Series "SWIFT-QUEUE" and by keeping only "}" as end of message use:
|
- To load a raw swift batch file "swift-batch-raw.txt" with "}\r\n" message break into the MQ/Series "SWIFT-QUEUE" and by keeping only "}" as end of message use:
|
||||||
java MQSLoad -mb "}\r\n" -mt "}" SWIFT-QUEUE swift-batch-raw.txt
|
java MQSLoad -mb "}\r\n" -mt "}" SWIFT-QUEUE swift-batch-raw.txt
|
||||||
|
|
||||||
- To load a csv batch file "batch.csv" with ";" field separator into the MQ/Series "DATA-QUEUE" use:
|
- To load a csv batch file "batch.csv" with ";" field separator into the MQ/Series "DATA-QUEUE" use:
|
||||||
java MQSLoad -fb ";" DATA-QUEUE csv-batch.csv
|
java MQSLoad -fb ";" DATA-QUEUE csv-batch.csv
|
||||||
|
@ -1,28 +1,13 @@
|
|||||||
# $RCSfile: ReleaseNotes.txt,v $
|
# $RCSfile: ReleaseNotes.txt,v $
|
||||||
# $Revision: 1.16 $
|
# $Revision: 1.11 $
|
||||||
# $Name: $
|
# $Name: $
|
||||||
# $Date: 2009/01/05 17:43:32 $
|
# $Date: 2008/11/14 00:00:51 $
|
||||||
# $Author: agibert $
|
# $Author: agibert $
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
MQSLoad V 2.0.0 - A. Gibert - 2008/01/05
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
- Major code rewrite and cleanup,
|
|
||||||
- Add message skip option "-ms",
|
|
||||||
- Add message count option "-mc",
|
|
||||||
- Add repeat count option "-rc",
|
|
||||||
- Add character set option "-cs",
|
|
||||||
- Add character convert option "-cc",
|
|
||||||
- Add message priority option "-mp",
|
|
||||||
- Fix Java 1.4 compatibility.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
MQSLoad V 1.3.2 - A. Gibert - 2008/11/14
|
MQSLoad V 1.3.2 - A. Gibert - 2008/11/14
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
9
ToDo.txt
9
ToDo.txt
@ -1,13 +1,12 @@
|
|||||||
# $RCSfile: ToDo.txt,v $
|
# $RCSfile: ToDo.txt,v $
|
||||||
# $Revision: 1.3 $
|
# $Revision: 1.2 $
|
||||||
# $Name: $
|
# $Name: $
|
||||||
# $Date: 2008/12/12 10:47:06 $
|
# $Date: 2002/04/23 16:25:50 $
|
||||||
# $Author: agibert $
|
# $Author: giberta1 $
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- Add stdin pipe support,
|
- write a better documentation !
|
||||||
- Write a better documentation !
|
|
||||||
- ...
|
- ...
|
||||||
|
Loading…
Reference in New Issue
Block a user