Compare commits

..

10 Commits

Author SHA1 Message Date
agibert
bf1d811041 - Add MQV7 support (Thanks to Yves MOYROUD !) 2013-11-08 17:15:45 +00:00
agibert
b7fcd00035 Minor fix. 2009-01-05 17:47:15 +00:00
agibert
44a23a3a7f Minor Cleanup. 2009-01-05 17:45:40 +00:00
agibert
d6b7c66a7b Fix release date. 2009-01-05 17:43:32 +00:00
agibert
5c1c862d5e Document new options and add an example. 2009-01-05 16:16:59 +00:00
agibert
c939079819 - Add message priority option "-mp",
- Fix usage print out.
2008-12-18 17:23:36 +00:00
agibert
87802fb8c3 - Fix "-cc" usage print. 2008-12-12 10:48:54 +00:00
agibert
d1b66d0c6f - start to improve docs... 2008-12-12 10:47:06 +00:00
agibert
0496074951 - Add character convert option "-cc" 2008-12-12 00:00:31 +00:00
agibert
ee82f99ecc - Minor code changes. 2008-12-11 14:17:18 +00:00
4 changed files with 114 additions and 48 deletions

View File

@ -1,12 +1,12 @@
// $RCSfile: MQSLoad.java,v $ // $RCSfile: MQSLoad.java,v $
// $Revision: 1.16 $ // $Revision: 1.22 $
// $Name: $ // $Name: $
// $Date: 2008/12/09 15:01:02 $ // $Date: 2013/11/08 17:15:45 $
// $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-2006 Arnaud G. Gibert * Copyright (C) 2001-2008 Arnaud G. Gibert
* mailto:arnaud@rx3.net * mailto:arnaud@rx3.net
* http://www.rx3.org/dvp/MQSLoad * http://www.rx3.org/dvp/MQSLoad
* *
@ -28,23 +28,23 @@
import java.io.*; import java.io.*;
import java.text.*; import java.text.*;
import com.ibm.mq.*; import com.ibm.mq.*;
import com.ibm.mq.constants.*;
public class MQSLoad public class MQSLoad
{ {
private String MQSLoad_Revision = "$Revision: 1.16 $"; private String MQSLoad_Revision = "$Revision: 1.22 $";
private String MQSLoad_Tag = "$Name: $"; private String MQSLoad_Tag = "$Name: $";
private String MQSLoad_Date = "$Date: 2008/12/09 15:01:02 $"; private String MQSLoad_Date = "$Date: 2013/11/08 17:15:45 $";
private String MQSLoad_Author = "$Author: agibert $"; 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 = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING; private int MsgQ_Open_Options = CMQC.MQOO_OUTPUT | CMQC.MQOO_FAIL_IF_QUIESCING;
private boolean Character_Convert = false;
private int Character_Set = 1208; private int Character_Set = 1208;
private int Message_Priority = CMQC.MQPRI_PRIORITY_AS_Q_DEF;
private int Sleep_Time = 0; 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";
@ -202,7 +202,7 @@ public class MQSLoad
// //
//------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------
private void Arg_Parse( String args[]) throws Exception private void Args_Parse( String args[]) throws Exception
{ {
int argc = 0; int argc = 0;
@ -223,6 +223,10 @@ public class MQSLoad
throw new Exception(); throw new Exception();
} }
} }
else if ( args[argc].equals( "-cc"))
{
Character_Convert = true;
}
else if ( args[argc].equals( "-cs")) else if ( args[argc].equals( "-cs"))
{ {
if( argc < ( args.length + 1)) if( argc < ( args.length + 1))
@ -235,6 +239,18 @@ public class MQSLoad
throw new Exception(); 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")) else if ( args[argc].equals( "-st"))
{ {
if( argc < ( args.length + 1)) if( argc < ( args.length + 1))
@ -583,29 +599,28 @@ public class MQSLoad
// //
//------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------
private int Msg_Put( MQMessage Output_Msg, int Msg_Id, int Msg_Nb, int Msg_Skip, int Msg_Count) throws Exception private boolean Msg_Put( MQMessage Output_Msg, int Msg_Id, int Msg_Skip, int Msg_Count) throws Exception
{ {
if( Msg_Id < Msg_Skip) if( Msg_Id < Msg_Skip)
{ {
Counter_Print( "*"); Counter_Print( "#");
Msg_Skiped_Nb++; Msg_Skiped_Nb++;
} }
else else
{ {
if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count))) if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count)))
{ {
Counter_Print( "#"); Counter_Print( "*");
Msg_Skiped_Nb++; Msg_Skiped_Nb++;
} }
else else
{ {
Output_Msg.messageId = MQC.MQMI_NONE; Output_Msg.messageId = CMQC.MQMI_NONE;
MQSPut_Msg( Output_Msg); MQSPut_Msg( Output_Msg);
Output_Msg.clearMessage(); Output_Msg.clearMessage();
Counter_Print( "."); Counter_Print( ".");
Msg_Nb++;
Msg_Read_Nb++; Msg_Read_Nb++;
Stand_By( Sleep_Time); Stand_By( Sleep_Time);
@ -617,11 +632,11 @@ public class MQSLoad
if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count))) if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count)))
{ {
/* Last Message to be read */ /* Last Message to be read */
return( -1); return( false);
} }
else else
{ {
return( Msg_Nb); return( true);
} }
} }
@ -643,13 +658,17 @@ public class MQSLoad
int buf_size, work_win_size, break_win_size, prefetch_size, fetch_size; 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 cur_buf_size, cur_work_win_size, cur_pos, msg_break;
int msg_id = 0; int msg_id = 0;
int msg_nb = 0;
try try
{ {
output_msg.format = MQC.MQFMT_STRING; if( Character_Convert)
{
output_msg.format = CMQC.MQFMT_STRING;
}
output_msg.characterSet = Character_Set; output_msg.characterSet = Character_Set;
output_msg.priority = Message_Priority;
work_win_size = 1024 * 64; work_win_size = 1024 * 64;
break_win_size = Field_Break.length() + message_break.length; break_win_size = Field_Break.length() + message_break.length;
@ -725,7 +744,7 @@ public class MQSLoad
/* send the message */ /* send the message */
// System.out.println( "* Put Msg()"); // System.out.println( "* Put Msg()");
if( ( msg_nb = Msg_Put( output_msg, msg_id, msg_nb, Msg_Skip, Msg_Count)) == -1) if( Msg_Put( output_msg, msg_id, Msg_Skip, Msg_Count) == false)
{ {
return; return;
} }
@ -754,7 +773,7 @@ public class MQSLoad
{ {
/* flush the message */ /* flush the message */
// System.out.println( "* Put Msg()"); // System.out.println( "* Put Msg()");
Msg_Put( output_msg, msg_id, msg_nb, Msg_Skip, Msg_Count); Msg_Put( output_msg, msg_id, Msg_Skip, Msg_Count);
} }
return; return;
@ -774,10 +793,11 @@ public class MQSLoad
// //
//------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------
private void Print_Usage( ) throws Exception private void Usage_Print( ) throws Exception
{ {
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( "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( " 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 + ")"); 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 + ")");
} }
@ -788,10 +808,10 @@ public class MQSLoad
// //
//------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------
private void Print_Args( ) throws Exception 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( "Output QueueMng Name: (" + QMng_Name + ") Output MsgQueue Name: (" + MsgQ_Name + ") Input File Name: (" + File_Name + ")");
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 + ")"); 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 + ")");
} }
@ -804,34 +824,37 @@ public class MQSLoad
public MQSLoad( String args[]) public MQSLoad( String args[])
{ {
int loop; int loop;
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 > 19))
{ {
Print_Usage(); Usage_Print();
System.exit( 1); System.exit( 1);
} }
else else
{ {
System.out.println( "MQS Load Starting..."); System.out.println( "MQS Load Starting...");
Arg_Parse( args); Args_Parse( args);
Print_Args(); Args_Print();
MQSInit(); MQSInit();
try try
{ {
RandomAccessFile input_file = new RandomAccessFile( File_Name, "r"); input_file = new RandomAccessFile( File_Name, "r");
System.out.println( "Legend: .: Loaded #: Skiped");
try try
{ {
// System.out.println("Input File Open: (" + input_file + ") !"); // System.out.println("Input File Open: (" + input_file + ") !");

View File

@ -1,7 +1,7 @@
# $RCSfile: ReadMe.txt,v $ # $RCSfile: ReadMe.txt,v $
# $Revision: 1.8 $ # $Revision: 1.11 $
# $Name: $ # $Name: $
# $Date: 2007/12/11 16:46:37 $ # $Date: 2009/01/05 17:45:40 $
# $Author: agibert $ # $Author: agibert $
@ -10,6 +10,7 @@
Compilation: Compilation:
------------ ------------
- Just type: "javac MQSLoad.java" ! - Just type: "javac MQSLoad.java" !
@ -21,11 +22,43 @@ 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 MQ/Series 5.2, 5.3 and WMQ 6.0 - MQSLoad has been tested with 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,
+ "\r" for return, + "\r" for return,
@ -54,9 +87,15 @@ 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

View File

@ -1,7 +1,7 @@
# $RCSfile: ReleaseNotes.txt,v $ # $RCSfile: ReleaseNotes.txt,v $
# $Revision: 1.12 $ # $Revision: 1.16 $
# $Name: $ # $Name: $
# $Date: 2008/12/04 10:45:06 $ # $Date: 2009/01/05 17:43:32 $
# $Author: agibert $ # $Author: agibert $
@ -9,13 +9,16 @@
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
MQSLoad V 2.0.0 - A. Gibert - 2008/12/03 MQSLoad V 2.0.0 - A. Gibert - 2008/01/05
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
- Major code cleanup, - Major code rewrite and cleanup,
- Add message skip option "-ms", - Add message skip option "-ms",
- Add message count option "-mc", - Add message count option "-mc",
- Add repeat count option "-rc", - 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. - Fix Java 1.4 compatibility.

View File

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