Compare commits

..

No commits in common. "bf1d81104161892a840ac5b5bea6b275c9e617f0" and "ffb13ee948489d9ad2834d4212be32aa3e329151" have entirely different histories.

4 changed files with 48 additions and 114 deletions

View File

@ -1,12 +1,12 @@
// $RCSfile: MQSLoad.java,v $
// $Revision: 1.22 $
// $Revision: 1.16 $
// $Name: $
// $Date: 2013/11/08 17:15:45 $
// $Date: 2008/12/09 15:01:02 $
// $Author: agibert $
/*
* 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
* http://www.rx3.org/dvp/MQSLoad
*
@ -28,23 +28,23 @@
import java.io.*;
import java.text.*;
import com.ibm.mq.*;
import com.ibm.mq.constants.*;
public class MQSLoad
{
private String MQSLoad_Revision = "$Revision: 1.22 $";
private String MQSLoad_Revision = "$Revision: 1.16 $";
private String MQSLoad_Tag = "$Name: $";
private String MQSLoad_Date = "$Date: 2013/11/08 17:15:45 $";
private String MQSLoad_Date = "$Date: 2008/12/09 15:01:02 $";
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 = CMQC.MQOO_OUTPUT | CMQC.MQOO_FAIL_IF_QUIESCING;
private boolean Character_Convert = false;
private int MsgQ_Open_Options = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;
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 Message_Break = "\r\n";
@ -202,7 +202,7 @@ public class MQSLoad
//
//-------------------------------------------------------------------------------------------------------------------------
private void Args_Parse( String args[]) throws Exception
private void Arg_Parse( String args[]) throws Exception
{
int argc = 0;
@ -223,10 +223,6 @@ public class MQSLoad
throw new Exception();
}
}
else if ( args[argc].equals( "-cc"))
{
Character_Convert = true;
}
else if ( args[argc].equals( "-cs"))
{
if( argc < ( args.length + 1))
@ -239,18 +235,6 @@ public class MQSLoad
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))
@ -599,28 +583,29 @@ public class MQSLoad
//
//-------------------------------------------------------------------------------------------------------------------------
private boolean Msg_Put( MQMessage Output_Msg, int Msg_Id, int Msg_Skip, int Msg_Count) throws Exception
private int Msg_Put( MQMessage Output_Msg, int Msg_Id, int Msg_Nb, int Msg_Skip, int Msg_Count) throws Exception
{
if( Msg_Id < Msg_Skip)
{
Counter_Print( "#");
Msg_Skiped_Nb++;
}
else
{
if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count)))
{
Counter_Print( "*");
Msg_Skiped_Nb++;
}
else
{
Output_Msg.messageId = CMQC.MQMI_NONE;
if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count)))
{
Counter_Print( "#");
Msg_Skiped_Nb++;
}
else
{
Output_Msg.messageId = MQC.MQMI_NONE;
MQSPut_Msg( Output_Msg);
Output_Msg.clearMessage();
Counter_Print( ".");
Msg_Nb++;
Msg_Read_Nb++;
Stand_By( Sleep_Time);
@ -632,11 +617,11 @@ public class MQSLoad
if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count)))
{
/* Last Message to be read */
return( false);
return( -1);
}
else
{
return( true);
return( Msg_Nb);
}
}
@ -658,17 +643,13 @@ public class MQSLoad
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;
int msg_nb = 0;
try
{
if( Character_Convert)
{
output_msg.format = CMQC.MQFMT_STRING;
}
output_msg.format = MQC.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;
@ -744,7 +725,7 @@ public class MQSLoad
/* send the message */
// System.out.println( "* Put Msg()");
if( Msg_Put( output_msg, msg_id, Msg_Skip, Msg_Count) == false)
if( ( msg_nb = Msg_Put( output_msg, msg_id, msg_nb, Msg_Skip, Msg_Count)) == -1)
{
return;
}
@ -773,7 +754,7 @@ public class MQSLoad
{
/* flush the message */
// System.out.println( "* Put Msg()");
Msg_Put( output_msg, msg_id, Msg_Skip, Msg_Count);
Msg_Put( output_msg, msg_id, msg_nb, Msg_Skip, Msg_Count);
}
return;
@ -793,11 +774,10 @@ public class MQSLoad
//
//-------------------------------------------------------------------------------------------------------------------------
private void Usage_Print( ) throws Exception
private void Print_Usage( ) 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 + ")");
System.out.println( "Usage: MQSLoad [-qm \"Output_QueueMng_Name\"] [-cs \"character_set\"] [-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( " Default: Output QueueMng Name: (" + QMng_Name + ") Character Set: (" + Character_Set + ") 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 + ")");
}
@ -808,10 +788,10 @@ public class MQSLoad
//
//-------------------------------------------------------------------------------------------------------------------------
private void Args_Print( ) throws Exception
private void Print_Args( ) 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 + ")");
System.out.println( "Character Set: (" + Character_Set + ") 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 + ")");
}
@ -828,7 +808,6 @@ public class MQSLoad
long time_begin, time_end;
double time_elapsed, speed;
NumberFormat nf = NumberFormat.getInstance();
RandomAccessFile input_file = null;
try
@ -837,23 +816,21 @@ public class MQSLoad
if( ( args.length < 2) || ( args.length > 19))
{
Usage_Print();
Print_Usage();
System.exit( 1);
}
else
{
System.out.println( "MQS Load Starting...");
Args_Parse( args);
Args_Print();
Arg_Parse( args);
Print_Args();
MQSInit();
try
{
input_file = new RandomAccessFile( File_Name, "r");
System.out.println( "Legend: .: Loaded #: Skiped");
RandomAccessFile input_file = new RandomAccessFile( File_Name, "r");
try
{

View File

@ -1,7 +1,7 @@
# $RCSfile: ReadMe.txt,v $
# $Revision: 1.11 $
# $Revision: 1.8 $
# $Name: $
# $Date: 2009/01/05 17:45:40 $
# $Date: 2007/12/11 16:46:37 $
# $Author: agibert $
@ -10,7 +10,6 @@
Compilation:
------------
- 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:
------
- 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:
+ "\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:
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:
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:
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:
java MQSLoad -fb ";" DATA-QUEUE csv-batch.csv

View File

@ -1,7 +1,7 @@
# $RCSfile: ReleaseNotes.txt,v $
# $Revision: 1.16 $
# $Revision: 1.12 $
# $Name: $
# $Date: 2009/01/05 17:43:32 $
# $Date: 2008/12/04 10:45:06 $
# $Author: agibert $
@ -9,16 +9,13 @@
--------------------------------------------------------------------------------
MQSLoad V 2.0.0 - A. Gibert - 2008/01/05
MQSLoad V 2.0.0 - A. Gibert - 2008/12/03
--------------------------------------------------------------------------------
- Major code rewrite and cleanup,
- Major code 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.

View File

@ -1,13 +1,12 @@
# $RCSfile: ToDo.txt,v $
# $Revision: 1.3 $
# $Revision: 1.2 $
# $Name: $
# $Date: 2008/12/12 10:47:06 $
# $Author: agibert $
# $Date: 2002/04/23 16:25:50 $
# $Author: giberta1 $
- Add stdin pipe support,
- Write a better documentation !
- write a better documentation !
- ...